All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joachim Eastwood <manabian@gmail.com>
To: peppe.cavallaro@st.com, davem@davemloft.net, mathieu@codeaurora.org
Cc: Joachim Eastwood <manabian@gmail.com>, netdev@vger.kernel.org
Subject: [PATCH net-next 03/17] stmmac: dwmac-ipq806x: turn setup callback into a probe function
Date: Wed, 29 Jul 2015 00:08:50 +0200	[thread overview]
Message-ID: <1438121344-5304-4-git-send-email-manabian@gmail.com> (raw)
In-Reply-To: <1438121344-5304-1-git-send-email-manabian@gmail.com>

By using a few functions from stmmac_platform a proper probe
function can be created from the setup glue callback. This
makes it look more like a standard driver and the OF match
data can also be dropped.

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
 .../net/ethernet/stmicro/stmmac/dwmac-ipq806x.c    | 38 +++++++++++++---------
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
index 5f1b3f9d8dba..333489f0fd24 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
@@ -255,23 +255,33 @@ static void ipq806x_gmac_fix_mac_speed(void *priv, unsigned int speed)
 	ipq806x_gmac_set_speed(gmac, speed);
 }
 
-static void *ipq806x_gmac_setup(struct platform_device *pdev)
+static int ipq806x_gmac_probe(struct platform_device *pdev)
 {
+	struct plat_stmmacenet_data *plat_dat;
+	struct stmmac_resources stmmac_res;
 	struct device *dev = &pdev->dev;
 	struct ipq806x_gmac *gmac;
 	int val;
 	void *err;
 
+	val = stmmac_get_platform_resources(pdev, &stmmac_res);
+	if (val)
+		return val;
+
+	plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac);
+	if (IS_ERR(plat_dat))
+		return PTR_ERR(plat_dat);
+
 	gmac = devm_kzalloc(dev, sizeof(*gmac), GFP_KERNEL);
 	if (!gmac)
-		return ERR_PTR(-ENOMEM);
+		return -ENOMEM;
 
 	gmac->pdev = pdev;
 
 	err = ipq806x_gmac_of_parse(gmac);
-	if (err) {
+	if (IS_ERR(err)) {
 		dev_err(dev, "device tree parsing error\n");
-		return err;
+		return PTR_ERR(err);
 	}
 
 	regmap_write(gmac->qsgmii_csr, QSGMII_PCS_CAL_LCKDT_CTL,
@@ -292,7 +302,7 @@ static void *ipq806x_gmac_setup(struct platform_device *pdev)
 	default:
 		dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n",
 			phy_modes(gmac->phy_mode));
-		return NULL;
+		return -EINVAL;
 	}
 	regmap_write(gmac->nss_common, NSS_COMMON_GMAC_CTL(gmac->id), val);
 
@@ -311,7 +321,7 @@ static void *ipq806x_gmac_setup(struct platform_device *pdev)
 	default:
 		dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n",
 			phy_modes(gmac->phy_mode));
-		return NULL;
+		return -EINVAL;
 	}
 	regmap_write(gmac->nss_common, NSS_COMMON_CLK_SRC_CTRL, val);
 
@@ -334,23 +344,21 @@ static void *ipq806x_gmac_setup(struct platform_device *pdev)
 			     0xC << QSGMII_PHY_TX_DRV_AMP_OFFSET);
 	}
 
-	return gmac;
-}
+	plat_dat->has_gmac = true;
+	plat_dat->bsp_priv = gmac;
+	plat_dat->fix_mac_speed = ipq806x_gmac_fix_mac_speed;
 
-static const struct stmmac_of_data ipq806x_gmac_data = {
-	.has_gmac	= 1,
-	.setup		= ipq806x_gmac_setup,
-	.fix_mac_speed	= ipq806x_gmac_fix_mac_speed,
-};
+	return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
+}
 
 static const struct of_device_id ipq806x_gmac_dwmac_match[] = {
-	{ .compatible = "qcom,ipq806x-gmac", .data = &ipq806x_gmac_data },
+	{ .compatible = "qcom,ipq806x-gmac" },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, ipq806x_gmac_dwmac_match);
 
 static struct platform_driver ipq806x_gmac_dwmac_driver = {
-	.probe = stmmac_pltfr_probe,
+	.probe = ipq806x_gmac_probe,
 	.remove = stmmac_pltfr_remove,
 	.driver = {
 		.name		= "ipq806x-gmac-dwmac",
-- 
1.8.0

  parent reply	other threads:[~2015-07-28 22:09 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-28 22:08 [PATCH net-next 00/17] stmmac clean up for 4.3 part2 Joachim Eastwood
2015-07-28 22:08 ` [PATCH net-next 01/17] stmmac: fix ptr_ret.cocci warning Joachim Eastwood
2015-07-28 22:08 ` [PATCH net-next 02/17] stmmac: dwmac-ipq806x: move ipq806x_gmac_fix_mac_speed function Joachim Eastwood
2015-07-28 22:08 ` Joachim Eastwood [this message]
2015-07-28 22:08 ` [PATCH net-next 04/17] stmmac: dwmac-socfpga: move socfpga_dwmac_probe function Joachim Eastwood
2015-07-28 22:08 ` [PATCH net-next 05/17] stmmac: dwmac-socfpga: turn setup callback into a probe function Joachim Eastwood
2015-07-28 22:08 ` [PATCH net-next 06/17] stmmac: dwmac-sunxi: move sun7i_gmac_setup function Joachim Eastwood
2015-07-28 22:08 ` [PATCH net-next 07/17] stmmac: dwmac-sunxi: turn setup callback into a probe function Joachim Eastwood
2015-07-28 22:08 ` [PATCH net-next 08/17] stmmac: dwmac-sti: " Joachim Eastwood
2015-07-28 22:08 ` [PATCH net-next 10/17] stmmac: move stmmac_pltfr_probe into dwmac-generic Joachim Eastwood
2015-07-28 22:08 ` [PATCH net-next 11/17] stmmac: let dwmac-* drivers handle their own match data Joachim Eastwood
2015-07-28 22:08 ` [PATCH net-next 12/17] stmmac: dwmac-sti: use custom of match structure Joachim Eastwood
     [not found] ` <1438121344-5304-1-git-send-email-manabian-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-07-28 22:08   ` [PATCH net-next 09/17] stmmac: dwmac-rk: create a new probe function Joachim Eastwood
2015-07-28 22:09   ` [PATCH net-next 13/17] stmmac: dwmac-rk: make rk_gmac_ops structs static const Joachim Eastwood
2015-07-28 22:09 ` [PATCH net-next 14/17] stmmac: dwmac-rk: use rk_gmac_ops as of match data Joachim Eastwood
2015-07-28 22:09 ` [PATCH net-next 15/17] stmmac: remove unused stmmac_of_data struct Joachim Eastwood
2015-07-28 22:09 ` [PATCH net-next 16/17] stmmac: remove setup/free glue callbacks Joachim Eastwood
2015-07-28 22:09 ` [PATCH net-next 17/17] stmmac: dwmac-sti: refactor the init " Joachim Eastwood
2015-07-29  7:13 ` [PATCH net-next 00/17] stmmac clean up for 4.3 part2 David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1438121344-5304-4-git-send-email-manabian@gmail.com \
    --to=manabian@gmail.com \
    --cc=davem@davemloft.net \
    --cc=mathieu@codeaurora.org \
    --cc=netdev@vger.kernel.org \
    --cc=peppe.cavallaro@st.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.