netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 00/17] stmmac clean up for 4.3 part2
@ 2015-07-28 22:08 Joachim Eastwood
  2015-07-28 22:08 ` [PATCH net-next 01/17] stmmac: fix ptr_ret.cocci warning Joachim Eastwood
                   ` (16 more replies)
  0 siblings, 17 replies; 19+ messages in thread
From: Joachim Eastwood @ 2015-07-28 22:08 UTC (permalink / raw)
  To: peppe.cavallaro, davem
  Cc: Joachim Eastwood, netdev, b.galvani, arnd, roger.chen, heiko,
	wens, dinguyen, linux-rockchip, mathieu

This patch set creates proper probe functions in the remaining
dwmac-* drivers, lets the drivers manage their own of match data
structure, and cleans up some of the drivers a bit. Note that
should be no functional change in any of the drivers.

First patch from Fengguang fixes a Coccinelle that was found after
the previous patch set when into next.

Probe functions are best placed just above the platform_driver
struct since it usually needs to call other functions in the
driver but this requires some code movement in the drivers. To
keep the conversion itself easier to review the code movement is
done in separate patches. This creates some extra churn but I
think it's worth it in this case.

As only a couple of drivers actually needs to use of match data
this pushed down from stmmac_platform and into the drivers. This
also makes it possible for drivers to have their own match data
structure. dwmac-rk benefits most from this.

After each driver has it's own probe function and manages it's
own match data the setup/free hooks and common match data struct
are removed.

Sorry for the slightly largish patch set this time around.


Since I can only test the core changes on my platform and not the
specific dwmac-drivers I greatly appreciate if people could test
this on their respective platforms. I did spend quite a bit of
time visually checking all these patches, but nothing beats real
hardware testing. Thanks!


Patch set based on net-next can also be picked up from here:
https://github.com/manabian/linux-lpc.git stmmac_4.3_part2

For those who want to have a look at all the patches for
v4.3 a branch based on Linus master can be found here:
https://github.com/manabian/linux-lpc.git stmmac_4.2


Previous parts can be found here:
http://www.spinics.net/lists/netdev/msg328997.html
http://www.spinics.net/lists/netdev/msg329932.html
http://www.spinics.net/lists/netdev/msg336097.html


Fengguang Wu (1):
  stmmac: fix ptr_ret.cocci warning

Joachim Eastwood (16):
  stmmac: dwmac-ipq806x: move ipq806x_gmac_fix_mac_speed function
  stmmac: dwmac-ipq806x: turn setup callback into a probe function
  stmmac: dwmac-socfpga: move socfpga_dwmac_probe function
  stmmac: dwmac-socfpga: turn setup callback into a probe function
  stmmac: dwmac-sunxi: move sun7i_gmac_setup function
  stmmac: dwmac-sunxi: turn setup callback into a probe function
  stmmac: dwmac-sti: turn setup callback into a probe function
  stmmac: dwmac-rk: create a new probe function
  stmmac: move stmmac_pltfr_probe into dwmac-generic
  stmmac: let dwmac-* drivers handle their own match data
  stmmac: dwmac-sti: use custom of match structure
  stmmac: dwmac-rk: make rk_gmac_ops structs static const
  stmmac: dwmac-rk: use rk_gmac_ops as of match data
  stmmac: remove unused stmmac_of_data struct
  stmmac: remove setup/free glue callbacks
  stmmac: dwmac-sti: refactor the init glue callbacks

 Documentation/networking/stmmac.txt                | 10 +--
 .../net/ethernet/stmicro/stmmac/dwmac-generic.c    | 42 +++++++++-
 .../net/ethernet/stmicro/stmmac/dwmac-ipq806x.c    | 50 +++++++-----
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c     | 73 ++++++++++-------
 .../net/ethernet/stmicro/stmmac/dwmac-socfpga.c    | 78 ++++++++++--------
 drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c    | 83 ++++++++++---------
 drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c  | 95 ++++++++++++----------
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  | 80 +-----------------
 .../net/ethernet/stmicro/stmmac/stmmac_platform.h  |  1 -
 include/linux/stmmac.h                             | 20 -----
 10 files changed, 260 insertions(+), 272 deletions(-)

-- 
1.8.0

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH net-next 01/17] stmmac: fix ptr_ret.cocci warning
  2015-07-28 22:08 [PATCH net-next 00/17] stmmac clean up for 4.3 part2 Joachim Eastwood
@ 2015-07-28 22:08 ` Joachim Eastwood
  2015-07-28 22:08 ` [PATCH net-next 02/17] stmmac: dwmac-ipq806x: move ipq806x_gmac_fix_mac_speed function Joachim Eastwood
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Joachim Eastwood @ 2015-07-28 22:08 UTC (permalink / raw)
  To: peppe.cavallaro, fengguang.wu, davem; +Cc: netdev, Joachim Eastwood

From: Fengguang Wu <fengguang.wu@intel.com>

drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c:304:1-3: WARNING: PTR_ERR_OR_ZERO can be used

Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR

Generated by: scripts/coccinelle/api/ptr_ret.cocci

Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
[je: rebase and insert newline before return]
Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index eca0eb845241..1dcb5ebefe5c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -298,10 +298,8 @@ int stmmac_get_platform_resources(struct platform_device *pdev,
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	stmmac_res->addr = devm_ioremap_resource(&pdev->dev, res);
-	if (IS_ERR(stmmac_res->addr))
-		return PTR_ERR(stmmac_res->addr);
 
-	return 0;
+	return PTR_ERR_OR_ZERO(stmmac_res->addr);
 }
 EXPORT_SYMBOL_GPL(stmmac_get_platform_resources);
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next 02/17] stmmac: dwmac-ipq806x: move ipq806x_gmac_fix_mac_speed function
  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 ` Joachim Eastwood
  2015-07-28 22:08 ` [PATCH net-next 03/17] stmmac: dwmac-ipq806x: turn setup callback into a probe function Joachim Eastwood
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Joachim Eastwood @ 2015-07-28 22:08 UTC (permalink / raw)
  To: peppe.cavallaro, davem, mathieu; +Cc: Joachim Eastwood, netdev

Move ipq806x_gmac_fix_mac_speed in preparation for turning
the setup glue callback in a proper probe function.

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

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
index 7e3129e7f143..5f1b3f9d8dba 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
@@ -248,6 +248,13 @@ static void *ipq806x_gmac_of_parse(struct ipq806x_gmac *gmac)
 	return NULL;
 }
 
+static void ipq806x_gmac_fix_mac_speed(void *priv, unsigned int speed)
+{
+	struct ipq806x_gmac *gmac = priv;
+
+	ipq806x_gmac_set_speed(gmac, speed);
+}
+
 static void *ipq806x_gmac_setup(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -330,13 +337,6 @@ static void *ipq806x_gmac_setup(struct platform_device *pdev)
 	return gmac;
 }
 
-static void ipq806x_gmac_fix_mac_speed(void *priv, unsigned int speed)
-{
-	struct ipq806x_gmac *gmac = priv;
-
-	ipq806x_gmac_set_speed(gmac, speed);
-}
-
 static const struct stmmac_of_data ipq806x_gmac_data = {
 	.has_gmac	= 1,
 	.setup		= ipq806x_gmac_setup,
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next 03/17] stmmac: dwmac-ipq806x: turn setup callback into a probe function
  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
  2015-07-28 22:08 ` [PATCH net-next 04/17] stmmac: dwmac-socfpga: move socfpga_dwmac_probe function Joachim Eastwood
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Joachim Eastwood @ 2015-07-28 22:08 UTC (permalink / raw)
  To: peppe.cavallaro, davem, mathieu; +Cc: Joachim Eastwood, netdev

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

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next 04/17] stmmac: dwmac-socfpga: move socfpga_dwmac_probe function
  2015-07-28 22:08 [PATCH net-next 00/17] stmmac clean up for 4.3 part2 Joachim Eastwood
                   ` (2 preceding siblings ...)
  2015-07-28 22:08 ` [PATCH net-next 03/17] stmmac: dwmac-ipq806x: turn setup callback into a probe function Joachim Eastwood
@ 2015-07-28 22:08 ` Joachim Eastwood
  2015-07-28 22:08 ` [PATCH net-next 05/17] stmmac: dwmac-socfpga: turn setup callback into a probe function Joachim Eastwood
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Joachim Eastwood @ 2015-07-28 22:08 UTC (permalink / raw)
  To: peppe.cavallaro, dinguyen, davem; +Cc: Joachim Eastwood, netdev

Move socfpga_dwmac_probe in preparation for turning it into
a proper probe function.

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

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
index 8141c5b844ae..0df409e2edcd 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
@@ -175,31 +175,6 @@ static int socfpga_dwmac_setup(struct socfpga_dwmac *dwmac)
 	return 0;
 }
 
-static void *socfpga_dwmac_probe(struct platform_device *pdev)
-{
-	struct device		*dev = &pdev->dev;
-	int			ret;
-	struct socfpga_dwmac	*dwmac;
-
-	dwmac = devm_kzalloc(dev, sizeof(*dwmac), GFP_KERNEL);
-	if (!dwmac)
-		return ERR_PTR(-ENOMEM);
-
-	ret = socfpga_dwmac_parse_data(dwmac, dev);
-	if (ret) {
-		dev_err(dev, "Unable to parse OF data\n");
-		return ERR_PTR(ret);
-	}
-
-	ret = socfpga_dwmac_setup(dwmac);
-	if (ret) {
-		dev_err(dev, "couldn't setup SoC glue (%d)\n", ret);
-		return ERR_PTR(ret);
-	}
-
-	return dwmac;
-}
-
 static void socfpga_dwmac_exit(struct platform_device *pdev, void *priv)
 {
 	struct socfpga_dwmac	*dwmac = priv;
@@ -257,6 +232,31 @@ static int socfpga_dwmac_init(struct platform_device *pdev, void *priv)
 	return ret;
 }
 
+static void *socfpga_dwmac_probe(struct platform_device *pdev)
+{
+	struct device		*dev = &pdev->dev;
+	int			ret;
+	struct socfpga_dwmac	*dwmac;
+
+	dwmac = devm_kzalloc(dev, sizeof(*dwmac), GFP_KERNEL);
+	if (!dwmac)
+		return ERR_PTR(-ENOMEM);
+
+	ret = socfpga_dwmac_parse_data(dwmac, dev);
+	if (ret) {
+		dev_err(dev, "Unable to parse OF data\n");
+		return ERR_PTR(ret);
+	}
+
+	ret = socfpga_dwmac_setup(dwmac);
+	if (ret) {
+		dev_err(dev, "couldn't setup SoC glue (%d)\n", ret);
+		return ERR_PTR(ret);
+	}
+
+	return dwmac;
+}
+
 static const struct stmmac_of_data socfpga_gmac_data = {
 	.setup = socfpga_dwmac_probe,
 	.init = socfpga_dwmac_init,
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next 05/17] stmmac: dwmac-socfpga: turn setup callback into a probe function
  2015-07-28 22:08 [PATCH net-next 00/17] stmmac clean up for 4.3 part2 Joachim Eastwood
                   ` (3 preceding siblings ...)
  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 ` Joachim Eastwood
  2015-07-28 22:08 ` [PATCH net-next 06/17] stmmac: dwmac-sunxi: move sun7i_gmac_setup function Joachim Eastwood
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Joachim Eastwood @ 2015-07-28 22:08 UTC (permalink / raw)
  To: peppe.cavallaro, dinguyen, davem; +Cc: Joachim Eastwood, netdev

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-socfpga.c    | 40 ++++++++++++++--------
 1 file changed, 26 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
index 0df409e2edcd..401383b252a8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
@@ -232,46 +232,58 @@ static int socfpga_dwmac_init(struct platform_device *pdev, void *priv)
 	return ret;
 }
 
-static void *socfpga_dwmac_probe(struct platform_device *pdev)
+static int socfpga_dwmac_probe(struct platform_device *pdev)
 {
+	struct plat_stmmacenet_data *plat_dat;
+	struct stmmac_resources stmmac_res;
 	struct device		*dev = &pdev->dev;
 	int			ret;
 	struct socfpga_dwmac	*dwmac;
 
+	ret = stmmac_get_platform_resources(pdev, &stmmac_res);
+	if (ret)
+		return ret;
+
+	plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac);
+	if (IS_ERR(plat_dat))
+		return PTR_ERR(plat_dat);
+
 	dwmac = devm_kzalloc(dev, sizeof(*dwmac), GFP_KERNEL);
 	if (!dwmac)
-		return ERR_PTR(-ENOMEM);
+		return -ENOMEM;
 
 	ret = socfpga_dwmac_parse_data(dwmac, dev);
 	if (ret) {
 		dev_err(dev, "Unable to parse OF data\n");
-		return ERR_PTR(ret);
+		return ret;
 	}
 
 	ret = socfpga_dwmac_setup(dwmac);
 	if (ret) {
 		dev_err(dev, "couldn't setup SoC glue (%d)\n", ret);
-		return ERR_PTR(ret);
+		return ret;
 	}
 
-	return dwmac;
-}
+	plat_dat->bsp_priv = dwmac;
+	plat_dat->init = socfpga_dwmac_init;
+	plat_dat->exit = socfpga_dwmac_exit;
+	plat_dat->fix_mac_speed = socfpga_dwmac_fix_mac_speed;
 
-static const struct stmmac_of_data socfpga_gmac_data = {
-	.setup = socfpga_dwmac_probe,
-	.init = socfpga_dwmac_init,
-	.exit = socfpga_dwmac_exit,
-	.fix_mac_speed = socfpga_dwmac_fix_mac_speed,
-};
+	ret = socfpga_dwmac_init(pdev, plat_dat->bsp_priv);
+	if (ret)
+		return ret;
+
+	return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
+}
 
 static const struct of_device_id socfpga_dwmac_match[] = {
-	{ .compatible = "altr,socfpga-stmmac", .data = &socfpga_gmac_data },
+	{ .compatible = "altr,socfpga-stmmac" },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, socfpga_dwmac_match);
 
 static struct platform_driver socfpga_dwmac_driver = {
-	.probe  = stmmac_pltfr_probe,
+	.probe  = socfpga_dwmac_probe,
 	.remove = stmmac_pltfr_remove,
 	.driver = {
 		.name           = "socfpga-dwmac",
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next 06/17] stmmac: dwmac-sunxi: move sun7i_gmac_setup function
  2015-07-28 22:08 [PATCH net-next 00/17] stmmac clean up for 4.3 part2 Joachim Eastwood
                   ` (4 preceding siblings ...)
  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 ` Joachim Eastwood
  2015-07-28 22:08 ` [PATCH net-next 07/17] stmmac: dwmac-sunxi: turn setup callback into a probe function Joachim Eastwood
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Joachim Eastwood @ 2015-07-28 22:08 UTC (permalink / raw)
  To: peppe.cavallaro, wens, davem; +Cc: Joachim Eastwood, netdev

Move sun7i_gmac_setup in preparation for turning it into
a proper probe function.

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c | 58 +++++++++++------------
 1 file changed, 29 insertions(+), 29 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
index 15048ca39759..c9d6e2d5bfc9 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
@@ -33,35 +33,6 @@ struct sunxi_priv_data {
 	struct regulator *regulator;
 };
 
-static void *sun7i_gmac_setup(struct platform_device *pdev)
-{
-	struct sunxi_priv_data *gmac;
-	struct device *dev = &pdev->dev;
-
-	gmac = devm_kzalloc(dev, sizeof(*gmac), GFP_KERNEL);
-	if (!gmac)
-		return ERR_PTR(-ENOMEM);
-
-	gmac->interface = of_get_phy_mode(dev->of_node);
-
-	gmac->tx_clk = devm_clk_get(dev, "allwinner_gmac_tx");
-	if (IS_ERR(gmac->tx_clk)) {
-		dev_err(dev, "could not get tx clock\n");
-		return gmac->tx_clk;
-	}
-
-	/* Optional regulator for PHY */
-	gmac->regulator = devm_regulator_get_optional(dev, "phy");
-	if (IS_ERR(gmac->regulator)) {
-		if (PTR_ERR(gmac->regulator) == -EPROBE_DEFER)
-			return ERR_PTR(-EPROBE_DEFER);
-		dev_info(dev, "no regulator found\n");
-		gmac->regulator = NULL;
-	}
-
-	return gmac;
-}
-
 #define SUN7I_GMAC_GMII_RGMII_RATE	125000000
 #define SUN7I_GMAC_MII_RATE		25000000
 
@@ -132,6 +103,35 @@ static void sun7i_fix_speed(void *priv, unsigned int speed)
 	}
 }
 
+static void *sun7i_gmac_setup(struct platform_device *pdev)
+{
+	struct sunxi_priv_data *gmac;
+	struct device *dev = &pdev->dev;
+
+	gmac = devm_kzalloc(dev, sizeof(*gmac), GFP_KERNEL);
+	if (!gmac)
+		return ERR_PTR(-ENOMEM);
+
+	gmac->interface = of_get_phy_mode(dev->of_node);
+
+	gmac->tx_clk = devm_clk_get(dev, "allwinner_gmac_tx");
+	if (IS_ERR(gmac->tx_clk)) {
+		dev_err(dev, "could not get tx clock\n");
+		return gmac->tx_clk;
+	}
+
+	/* Optional regulator for PHY */
+	gmac->regulator = devm_regulator_get_optional(dev, "phy");
+	if (IS_ERR(gmac->regulator)) {
+		if (PTR_ERR(gmac->regulator) == -EPROBE_DEFER)
+			return ERR_PTR(-EPROBE_DEFER);
+		dev_info(dev, "no regulator found\n");
+		gmac->regulator = NULL;
+	}
+
+	return gmac;
+}
+
 /* of_data specifying hardware features and callbacks.
  * hardware features were copied from Allwinner drivers. */
 static const struct stmmac_of_data sun7i_gmac_data = {
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next 07/17] stmmac: dwmac-sunxi: turn setup callback into a probe function
  2015-07-28 22:08 [PATCH net-next 00/17] stmmac clean up for 4.3 part2 Joachim Eastwood
                   ` (5 preceding siblings ...)
  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 ` Joachim Eastwood
  2015-07-28 22:08 ` [PATCH net-next 08/17] stmmac: dwmac-sti: " Joachim Eastwood
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Joachim Eastwood @ 2015-07-28 22:08 UTC (permalink / raw)
  To: peppe.cavallaro, wens, davem; +Cc: Joachim Eastwood, netdev

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>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c | 49 ++++++++++++++---------
 1 file changed, 31 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
index c9d6e2d5bfc9..52b8ed9bd87c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
@@ -103,54 +103,67 @@ static void sun7i_fix_speed(void *priv, unsigned int speed)
 	}
 }
 
-static void *sun7i_gmac_setup(struct platform_device *pdev)
+static int sun7i_gmac_probe(struct platform_device *pdev)
 {
+	struct plat_stmmacenet_data *plat_dat;
+	struct stmmac_resources stmmac_res;
 	struct sunxi_priv_data *gmac;
 	struct device *dev = &pdev->dev;
+	int ret;
+
+	ret = stmmac_get_platform_resources(pdev, &stmmac_res);
+	if (ret)
+		return ret;
+
+	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->interface = of_get_phy_mode(dev->of_node);
 
 	gmac->tx_clk = devm_clk_get(dev, "allwinner_gmac_tx");
 	if (IS_ERR(gmac->tx_clk)) {
 		dev_err(dev, "could not get tx clock\n");
-		return gmac->tx_clk;
+		return PTR_ERR(gmac->tx_clk);
 	}
 
 	/* Optional regulator for PHY */
 	gmac->regulator = devm_regulator_get_optional(dev, "phy");
 	if (IS_ERR(gmac->regulator)) {
 		if (PTR_ERR(gmac->regulator) == -EPROBE_DEFER)
-			return ERR_PTR(-EPROBE_DEFER);
+			return -EPROBE_DEFER;
 		dev_info(dev, "no regulator found\n");
 		gmac->regulator = NULL;
 	}
 
-	return gmac;
-}
+	/* platform data specifying hardware features and callbacks.
+	 * hardware features were copied from Allwinner drivers. */
+	plat_dat->tx_coe = 1;
+	plat_dat->has_gmac = true;
+	plat_dat->bsp_priv = gmac;
+	plat_dat->init = sun7i_gmac_init;
+	plat_dat->exit = sun7i_gmac_exit;
+	plat_dat->fix_mac_speed = sun7i_fix_speed;
 
-/* of_data specifying hardware features and callbacks.
- * hardware features were copied from Allwinner drivers. */
-static const struct stmmac_of_data sun7i_gmac_data = {
-	.has_gmac = 1,
-	.tx_coe = 1,
-	.fix_mac_speed = sun7i_fix_speed,
-	.setup = sun7i_gmac_setup,
-	.init = sun7i_gmac_init,
-	.exit = sun7i_gmac_exit,
-};
+	ret = sun7i_gmac_init(pdev, plat_dat->bsp_priv);
+	if (ret)
+		return ret;
+
+	return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
+}
 
 static const struct of_device_id sun7i_dwmac_match[] = {
-	{ .compatible = "allwinner,sun7i-a20-gmac", .data = &sun7i_gmac_data},
+	{ .compatible = "allwinner,sun7i-a20-gmac" },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, sun7i_dwmac_match);
 
 static struct platform_driver sun7i_dwmac_driver = {
-	.probe  = stmmac_pltfr_probe,
+	.probe  = sun7i_gmac_probe,
 	.remove = stmmac_pltfr_remove,
 	.driver = {
 		.name           = "sun7i-dwmac",
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next 08/17] stmmac: dwmac-sti: turn setup callback into a probe function
  2015-07-28 22:08 [PATCH net-next 00/17] stmmac clean up for 4.3 part2 Joachim Eastwood
                   ` (6 preceding siblings ...)
  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 ` Joachim Eastwood
  2015-07-28 22:08 ` [PATCH net-next 10/17] stmmac: move stmmac_pltfr_probe into dwmac-generic Joachim Eastwood
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Joachim Eastwood @ 2015-07-28 22:08 UTC (permalink / raw)
  To: peppe.cavallaro, srinivas.kandagatla, davem
  Cc: Joachim Eastwood, netdev, kernel

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 prepares the
driver for further clean ups.

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c | 31 ++++++++++++++++++-------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
index a2e8111c5d14..b17238aac791 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
@@ -334,36 +334,49 @@ static int sti_dwmac_parse_data(struct sti_dwmac *dwmac,
 	return 0;
 }
 
-static void *sti_dwmac_setup(struct platform_device *pdev)
+static int sti_dwmac_probe(struct platform_device *pdev)
 {
+	struct plat_stmmacenet_data *plat_dat;
+	struct stmmac_resources stmmac_res;
 	struct sti_dwmac *dwmac;
 	int ret;
 
+	ret = stmmac_get_platform_resources(pdev, &stmmac_res);
+	if (ret)
+		return ret;
+
+	plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac);
+	if (IS_ERR(plat_dat))
+		return PTR_ERR(plat_dat);
+
 	dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
 	if (!dwmac)
-		return ERR_PTR(-ENOMEM);
+		return -ENOMEM;
 
 	ret = sti_dwmac_parse_data(dwmac, pdev);
 	if (ret) {
 		dev_err(&pdev->dev, "Unable to parse OF data\n");
-		return ERR_PTR(ret);
+		return ret;
 	}
 
-	return dwmac;
+	plat_dat->bsp_priv = dwmac;
+	plat_dat->exit = sti_dwmac_exit;
+
+	ret = plat_dat->init(pdev, plat_dat->bsp_priv);
+	if (ret)
+		return ret;
+
+	return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
 }
 
 static const struct stmmac_of_data stih4xx_dwmac_data = {
 	.fix_mac_speed = stih4xx_fix_retime_src,
-	.setup = sti_dwmac_setup,
 	.init = stix4xx_init,
-	.exit = sti_dwmac_exit,
 };
 
 static const struct stmmac_of_data stid127_dwmac_data = {
 	.fix_mac_speed = stid127_fix_retime_src,
-	.setup = sti_dwmac_setup,
 	.init = stid127_init,
-	.exit = sti_dwmac_exit,
 };
 
 static const struct of_device_id sti_dwmac_match[] = {
@@ -376,7 +389,7 @@ static const struct of_device_id sti_dwmac_match[] = {
 MODULE_DEVICE_TABLE(of, sti_dwmac_match);
 
 static struct platform_driver sti_dwmac_driver = {
-	.probe  = stmmac_pltfr_probe,
+	.probe  = sti_dwmac_probe,
 	.remove = stmmac_pltfr_remove,
 	.driver = {
 		.name           = "sti-dwmac",
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next 09/17] stmmac: dwmac-rk: create a new probe function
       [not found] ` <1438121344-5304-1-git-send-email-manabian-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2015-07-28 22:08   ` Joachim Eastwood
  2015-07-28 22:09   ` [PATCH net-next 13/17] stmmac: dwmac-rk: make rk_gmac_ops structs static const Joachim Eastwood
  1 sibling, 0 replies; 19+ messages in thread
From: Joachim Eastwood @ 2015-07-28 22:08 UTC (permalink / raw)
  To: peppe.cavallaro-qxv4g6HH51o, heiko-4mtYJXux2i+zQB+pC5nmwQ,
	roger.chen-TNX95d0MmH7DzftRWevZcw, davem-fT/PcQaiUtIeIZ0/mPfg9Q
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, Joachim Eastwood,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

Create a new probe functions that call the necessary setup
functions. This is done in preparation for a code refactor
in this driver and dropping the common probe function in
stmmac_platform.c.

Signed-off-by: Joachim Eastwood <manabian-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 40 ++++++++++++++++++++------
 1 file changed, 31 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index 00a1e1e09d4f..21193a73acfc 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -576,20 +576,42 @@ static void rk_fix_speed(void *priv, unsigned int speed)
 		dev_err(dev, "unsupported interface %d", bsp_priv->phy_iface);
 }
 
+static int rk_gmac_probe(struct platform_device *pdev)
+{
+	struct plat_stmmacenet_data *plat_dat;
+	struct stmmac_resources stmmac_res;
+	int ret;
+
+	ret = stmmac_get_platform_resources(pdev, &stmmac_res);
+	if (ret)
+		return ret;
+
+	plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac);
+	if (IS_ERR(plat_dat))
+		return PTR_ERR(plat_dat);
+
+	plat_dat->has_gmac = true;
+	plat_dat->init = rk_gmac_init;
+	plat_dat->exit = rk_gmac_exit;
+	plat_dat->fix_mac_speed = rk_fix_speed;
+
+	plat_dat->bsp_priv = plat_dat->setup(pdev);
+	if (IS_ERR(plat_dat->bsp_priv))
+		return PTR_ERR(plat_dat->bsp_priv);
+
+	ret = rk_gmac_init(pdev, plat_dat->bsp_priv);
+	if (ret)
+		return ret;
+
+	return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
+}
+
 static const struct stmmac_of_data rk3288_gmac_data = {
-	.has_gmac = 1,
-	.fix_mac_speed = rk_fix_speed,
 	.setup = rk3288_gmac_setup,
-	.init = rk_gmac_init,
-	.exit = rk_gmac_exit,
 };
 
 static const struct stmmac_of_data rk3368_gmac_data = {
-	.has_gmac = 1,
-	.fix_mac_speed = rk_fix_speed,
 	.setup = rk3368_gmac_setup,
-	.init = rk_gmac_init,
-	.exit = rk_gmac_exit,
 };
 
 static const struct of_device_id rk_gmac_dwmac_match[] = {
@@ -600,7 +622,7 @@ static const struct of_device_id rk_gmac_dwmac_match[] = {
 MODULE_DEVICE_TABLE(of, rk_gmac_dwmac_match);
 
 static struct platform_driver rk_gmac_dwmac_driver = {
-	.probe  = stmmac_pltfr_probe,
+	.probe  = rk_gmac_probe,
 	.remove = stmmac_pltfr_remove,
 	.driver = {
 		.name           = "rk_gmac-dwmac",
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next 10/17] stmmac: move stmmac_pltfr_probe into dwmac-generic
  2015-07-28 22:08 [PATCH net-next 00/17] stmmac clean up for 4.3 part2 Joachim Eastwood
                   ` (7 preceding siblings ...)
  2015-07-28 22:08 ` [PATCH net-next 08/17] stmmac: dwmac-sti: " Joachim Eastwood
@ 2015-07-28 22:08 ` Joachim Eastwood
  2015-07-28 22:08 ` [PATCH net-next 11/17] stmmac: let dwmac-* drivers handle their own match data Joachim Eastwood
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Joachim Eastwood @ 2015-07-28 22:08 UTC (permalink / raw)
  To: peppe.cavallaro, davem; +Cc: Joachim Eastwood, netdev

As all dwmac-* drivers now have their own probe function move
the common one into dwmac-generic driver and drop the EXPORT.

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
 .../net/ethernet/stmicro/stmmac/dwmac-generic.c    | 49 ++++++++++++++++++-
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  | 55 ----------------------
 .../net/ethernet/stmicro/stmmac/stmmac_platform.h  |  1 -
 3 files changed, 48 insertions(+), 57 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c
index e817a1a44379..f4fe9f1a33b4 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c
@@ -16,6 +16,53 @@
 #include "stmmac.h"
 #include "stmmac_platform.h"
 
+static int dwmac_generic_probe(struct platform_device *pdev)
+{
+	struct plat_stmmacenet_data *plat_dat;
+	struct stmmac_resources stmmac_res;
+	int ret;
+
+	ret = stmmac_get_platform_resources(pdev, &stmmac_res);
+	if (ret)
+		return ret;
+
+	if (pdev->dev.of_node) {
+		plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac);
+		if (IS_ERR(plat_dat)) {
+			dev_err(&pdev->dev, "dt configuration failed\n");
+			return PTR_ERR(plat_dat);
+		}
+	} else {
+		plat_dat = dev_get_platdata(&pdev->dev);
+		if (!plat_dat) {
+			dev_err(&pdev->dev, "no platform data provided\n");
+			return  -EINVAL;
+		}
+
+		/* Set default value for multicast hash bins */
+		plat_dat->multicast_filter_bins = HASH_TABLE_SIZE;
+
+		/* Set default value for unicast filter entries */
+		plat_dat->unicast_filter_entries = 1;
+	}
+
+	/* Custom setup (if needed) */
+	if (plat_dat->setup) {
+		plat_dat->bsp_priv = plat_dat->setup(pdev);
+		if (IS_ERR(plat_dat->bsp_priv))
+			return PTR_ERR(plat_dat->bsp_priv);
+	}
+
+	/* Custom initialisation (if needed) */
+	if (plat_dat->init) {
+		ret = plat_dat->init(pdev, plat_dat->bsp_priv);
+		if (ret)
+			return ret;
+	}
+
+	return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
+}
+
 static const struct of_device_id dwmac_generic_match[] = {
 	{ .compatible = "st,spear600-gmac"},
 	{ .compatible = "snps,dwmac-3.610"},
@@ -27,7 +74,7 @@ static const struct of_device_id dwmac_generic_match[] = {
 MODULE_DEVICE_TABLE(of, dwmac_generic_match);
 
 static struct platform_driver dwmac_generic_driver = {
-	.probe  = stmmac_pltfr_probe,
+	.probe  = dwmac_generic_probe,
 	.remove = stmmac_pltfr_remove,
 	.driver = {
 		.name           = STMMAC_RESOURCE_NAME,
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 1dcb5ebefe5c..9c49d95e529a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -304,61 +304,6 @@ int stmmac_get_platform_resources(struct platform_device *pdev,
 EXPORT_SYMBOL_GPL(stmmac_get_platform_resources);
 
 /**
- * stmmac_pltfr_probe - platform driver probe.
- * @pdev: platform device pointer
- * Description: platform_device probe function. It is to allocate
- * the necessary platform resources, invoke custom helper (if required) and
- * invoke the main probe function.
- */
-int stmmac_pltfr_probe(struct platform_device *pdev)
-{
-	struct plat_stmmacenet_data *plat_dat;
-	struct stmmac_resources stmmac_res;
-	int ret;
-
-	ret = stmmac_get_platform_resources(pdev, &stmmac_res);
-	if (ret)
-		return ret;
-
-	if (pdev->dev.of_node) {
-		plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac);
-		if (IS_ERR(plat_dat)) {
-			dev_err(&pdev->dev, "dt configuration failed\n");
-			return PTR_ERR(plat_dat);
-		}
-	} else {
-		plat_dat = dev_get_platdata(&pdev->dev);
-		if (!plat_dat) {
-			dev_err(&pdev->dev, "no platform data provided\n");
-			return  -EINVAL;
-		}
-
-		/* Set default value for multicast hash bins */
-		plat_dat->multicast_filter_bins = HASH_TABLE_SIZE;
-
-		/* Set default value for unicast filter entries */
-		plat_dat->unicast_filter_entries = 1;
-	}
-
-	/* Custom setup (if needed) */
-	if (plat_dat->setup) {
-		plat_dat->bsp_priv = plat_dat->setup(pdev);
-		if (IS_ERR(plat_dat->bsp_priv))
-			return PTR_ERR(plat_dat->bsp_priv);
-	}
-
-	/* Custom initialisation (if needed)*/
-	if (plat_dat->init) {
-		ret = plat_dat->init(pdev, plat_dat->bsp_priv);
-		if (unlikely(ret))
-			return ret;
-	}
-
-	return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
-}
-EXPORT_SYMBOL_GPL(stmmac_pltfr_probe);
-
-/**
  * stmmac_pltfr_remove
  * @pdev: platform device pointer
  * Description: this function calls the main to free the net resources
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h
index 84ceb5342686..ffeb8d9e2b2e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h
@@ -27,7 +27,6 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac);
 int stmmac_get_platform_resources(struct platform_device *pdev,
 				  struct stmmac_resources *stmmac_res);
 
-int stmmac_pltfr_probe(struct platform_device *pdev);
 int stmmac_pltfr_remove(struct platform_device *pdev);
 extern const struct dev_pm_ops stmmac_pltfr_pm_ops;
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next 11/17] stmmac: let dwmac-* drivers handle their own match data
  2015-07-28 22:08 [PATCH net-next 00/17] stmmac clean up for 4.3 part2 Joachim Eastwood
                   ` (8 preceding siblings ...)
  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 ` Joachim Eastwood
  2015-07-28 22:08 ` [PATCH net-next 12/17] stmmac: dwmac-sti: use custom of match structure Joachim Eastwood
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Joachim Eastwood @ 2015-07-28 22:08 UTC (permalink / raw)
  To: peppe.cavallaro, davem; +Cc: Joachim Eastwood, netdev

Since only a few of the dwmac-* drivers actually need to use
the OF match move handling into the dwmac-* drivers that need
it. This will also allow dwmac-* drivers to use their own
custom match data structure.

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c        |  8 ++++++++
 drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c       | 10 ++++++++++
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 18 ------------------
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index 21193a73acfc..65c1e1afe6a8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -580,8 +580,15 @@ static int rk_gmac_probe(struct platform_device *pdev)
 {
 	struct plat_stmmacenet_data *plat_dat;
 	struct stmmac_resources stmmac_res;
+	const struct stmmac_of_data *data;
 	int ret;
 
+	data = of_device_get_match_data(&pdev->dev);
+	if (!data) {
+		dev_err(&pdev->dev, "no of match data provided\n");
+		return -EINVAL;
+	}
+
 	ret = stmmac_get_platform_resources(pdev, &stmmac_res);
 	if (ret)
 		return ret;
@@ -591,6 +598,7 @@ static int rk_gmac_probe(struct platform_device *pdev)
 		return PTR_ERR(plat_dat);
 
 	plat_dat->has_gmac = true;
+	plat_dat->setup = data->setup;
 	plat_dat->init = rk_gmac_init;
 	plat_dat->exit = rk_gmac_exit;
 	plat_dat->fix_mac_speed = rk_fix_speed;
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
index b17238aac791..8a977fde1a46 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
@@ -21,6 +21,7 @@
 #include <linux/regmap.h>
 #include <linux/clk.h>
 #include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/of_net.h>
 
 #include "stmmac_platform.h"
@@ -337,10 +338,17 @@ static int sti_dwmac_parse_data(struct sti_dwmac *dwmac,
 static int sti_dwmac_probe(struct platform_device *pdev)
 {
 	struct plat_stmmacenet_data *plat_dat;
+	const struct stmmac_of_data *data;
 	struct stmmac_resources stmmac_res;
 	struct sti_dwmac *dwmac;
 	int ret;
 
+	data = of_device_get_match_data(&pdev->dev);
+	if (!data) {
+		dev_err(&pdev->dev, "No OF match data provided\n");
+		return -EINVAL;
+	}
+
 	ret = stmmac_get_platform_resources(pdev, &stmmac_res);
 	if (ret)
 		return ret;
@@ -360,7 +368,9 @@ static int sti_dwmac_probe(struct platform_device *pdev)
 	}
 
 	plat_dat->bsp_priv = dwmac;
+	plat_dat->init = data->init;
 	plat_dat->exit = sti_dwmac_exit;
+	plat_dat->fix_mac_speed = data->fix_mac_speed;
 
 	ret = plat_dat->init(pdev, plat_dat->bsp_priv);
 	if (ret)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 9c49d95e529a..55e569b330b2 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -109,30 +109,12 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 {
 	struct device_node *np = pdev->dev.of_node;
 	struct plat_stmmacenet_data *plat;
-	const struct stmmac_of_data *data;
 	struct stmmac_dma_cfg *dma_cfg;
 
 	plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
 	if (!plat)
 		return ERR_PTR(-ENOMEM);
 
-	data = of_device_get_match_data(&pdev->dev);
-	if (data) {
-		plat->has_gmac = data->has_gmac;
-		plat->enh_desc = data->enh_desc;
-		plat->tx_coe = data->tx_coe;
-		plat->rx_coe = data->rx_coe;
-		plat->bugged_jumbo = data->bugged_jumbo;
-		plat->pmt = data->pmt;
-		plat->riwt_off = data->riwt_off;
-		plat->fix_mac_speed = data->fix_mac_speed;
-		plat->bus_setup = data->bus_setup;
-		plat->setup = data->setup;
-		plat->free = data->free;
-		plat->init = data->init;
-		plat->exit = data->exit;
-	}
-
 	*mac = of_get_mac_address(np);
 	plat->interface = of_get_phy_mode(np);
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next 12/17] stmmac: dwmac-sti: use custom of match structure
  2015-07-28 22:08 [PATCH net-next 00/17] stmmac clean up for 4.3 part2 Joachim Eastwood
                   ` (9 preceding siblings ...)
  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 ` Joachim Eastwood
       [not found] ` <1438121344-5304-1-git-send-email-manabian-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Joachim Eastwood @ 2015-07-28 22:08 UTC (permalink / raw)
  To: peppe.cavallaro, srinivas.kandagatla, davem
  Cc: Joachim Eastwood, netdev, kernel

Create a new private structure for OF match data in the
dwmac-sti driver. This enables us to eventually drop the
common OF match data structure which contains a lot of
unused fields.

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
index 8a977fde1a46..83c501edb688 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
@@ -131,6 +131,11 @@ struct sti_dwmac {
 	u32 speed;
 };
 
+struct sti_dwmac_of_data {
+	void (*fix_mac_speed)(void *priv, unsigned int speed);
+	int (*init)(struct platform_device *pdev, void *priv);
+};
+
 static u32 phy_intf_sels[] = {
 	[PHY_INTERFACE_MODE_MII] = ETH_PHY_SEL_MII,
 	[PHY_INTERFACE_MODE_GMII] = ETH_PHY_SEL_GMII,
@@ -338,7 +343,7 @@ static int sti_dwmac_parse_data(struct sti_dwmac *dwmac,
 static int sti_dwmac_probe(struct platform_device *pdev)
 {
 	struct plat_stmmacenet_data *plat_dat;
-	const struct stmmac_of_data *data;
+	const struct sti_dwmac_of_data *data;
 	struct stmmac_resources stmmac_res;
 	struct sti_dwmac *dwmac;
 	int ret;
@@ -379,12 +384,12 @@ static int sti_dwmac_probe(struct platform_device *pdev)
 	return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
 }
 
-static const struct stmmac_of_data stih4xx_dwmac_data = {
+static const struct sti_dwmac_of_data stih4xx_dwmac_data = {
 	.fix_mac_speed = stih4xx_fix_retime_src,
 	.init = stix4xx_init,
 };
 
-static const struct stmmac_of_data stid127_dwmac_data = {
+static const struct sti_dwmac_of_data stid127_dwmac_data = {
 	.fix_mac_speed = stid127_fix_retime_src,
 	.init = stid127_init,
 };
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next 13/17] stmmac: dwmac-rk: make rk_gmac_ops structs static const
       [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   ` Joachim Eastwood
  1 sibling, 0 replies; 19+ messages in thread
From: Joachim Eastwood @ 2015-07-28 22:09 UTC (permalink / raw)
  To: peppe.cavallaro-qxv4g6HH51o, heiko-4mtYJXux2i+zQB+pC5nmwQ,
	roger.chen-TNX95d0MmH7DzftRWevZcw, davem-fT/PcQaiUtIeIZ0/mPfg9Q
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, Joachim Eastwood,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

Mark the rk_gmac_ops structures as static const as they should be.

Signed-off-by: Joachim Eastwood <manabian-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index 65c1e1afe6a8..5d8042ea8370 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -46,7 +46,7 @@ struct rk_priv_data {
 	struct platform_device *pdev;
 	int phy_iface;
 	struct regulator *regulator;
-	struct rk_gmac_ops *ops;
+	const struct rk_gmac_ops *ops;
 
 	bool clk_enabled;
 	bool clock_input;
@@ -177,7 +177,7 @@ static void rk3288_set_rmii_speed(struct rk_priv_data *bsp_priv, int speed)
 	}
 }
 
-struct rk_gmac_ops rk3288_ops = {
+static const struct rk_gmac_ops rk3288_ops = {
 	.set_to_rgmii = rk3288_set_to_rgmii,
 	.set_to_rmii = rk3288_set_to_rmii,
 	.set_rgmii_speed = rk3288_set_rgmii_speed,
@@ -289,7 +289,7 @@ static void rk3368_set_rmii_speed(struct rk_priv_data *bsp_priv, int speed)
 	}
 }
 
-struct rk_gmac_ops rk3368_ops = {
+static const struct rk_gmac_ops rk3368_ops = {
 	.set_to_rgmii = rk3368_set_to_rgmii,
 	.set_to_rmii = rk3368_set_to_rmii,
 	.set_rgmii_speed = rk3368_set_rgmii_speed,
@@ -448,7 +448,7 @@ static int phy_power_on(struct rk_priv_data *bsp_priv, bool enable)
 }
 
 static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev,
-					  struct rk_gmac_ops *ops)
+					  const struct rk_gmac_ops *ops)
 {
 	struct rk_priv_data *bsp_priv;
 	struct device *dev = &pdev->dev;
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next 14/17] stmmac: dwmac-rk: use rk_gmac_ops as of match data
  2015-07-28 22:08 [PATCH net-next 00/17] stmmac clean up for 4.3 part2 Joachim Eastwood
                   ` (11 preceding siblings ...)
       [not found] ` <1438121344-5304-1-git-send-email-manabian-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2015-07-28 22:09 ` Joachim Eastwood
  2015-07-28 22:09 ` [PATCH net-next 15/17] stmmac: remove unused stmmac_of_data struct Joachim Eastwood
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Joachim Eastwood @ 2015-07-28 22:09 UTC (permalink / raw)
  To: peppe.cavallaro, heiko, roger.chen, davem
  Cc: Joachim Eastwood, netdev, linux-rockchip

Remove the setup glue callback and use rk_gmac_ops as OF match
data so it can used directly when calling rk_gmac_setup.

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

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index 5d8042ea8370..11baa4b19779 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -529,16 +529,6 @@ static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev,
 	return bsp_priv;
 }
 
-static void *rk3288_gmac_setup(struct platform_device *pdev)
-{
-	return rk_gmac_setup(pdev, &rk3288_ops);
-}
-
-static void *rk3368_gmac_setup(struct platform_device *pdev)
-{
-	return rk_gmac_setup(pdev, &rk3368_ops);
-}
-
 static int rk_gmac_init(struct platform_device *pdev, void *priv)
 {
 	struct rk_priv_data *bsp_priv = priv;
@@ -580,7 +570,7 @@ static int rk_gmac_probe(struct platform_device *pdev)
 {
 	struct plat_stmmacenet_data *plat_dat;
 	struct stmmac_resources stmmac_res;
-	const struct stmmac_of_data *data;
+	const struct rk_gmac_ops *data;
 	int ret;
 
 	data = of_device_get_match_data(&pdev->dev);
@@ -598,12 +588,11 @@ static int rk_gmac_probe(struct platform_device *pdev)
 		return PTR_ERR(plat_dat);
 
 	plat_dat->has_gmac = true;
-	plat_dat->setup = data->setup;
 	plat_dat->init = rk_gmac_init;
 	plat_dat->exit = rk_gmac_exit;
 	plat_dat->fix_mac_speed = rk_fix_speed;
 
-	plat_dat->bsp_priv = plat_dat->setup(pdev);
+	plat_dat->bsp_priv = rk_gmac_setup(pdev, data);
 	if (IS_ERR(plat_dat->bsp_priv))
 		return PTR_ERR(plat_dat->bsp_priv);
 
@@ -614,17 +603,9 @@ static int rk_gmac_probe(struct platform_device *pdev)
 	return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
 }
 
-static const struct stmmac_of_data rk3288_gmac_data = {
-	.setup = rk3288_gmac_setup,
-};
-
-static const struct stmmac_of_data rk3368_gmac_data = {
-	.setup = rk3368_gmac_setup,
-};
-
 static const struct of_device_id rk_gmac_dwmac_match[] = {
-	{ .compatible = "rockchip,rk3288-gmac", .data = &rk3288_gmac_data},
-	{ .compatible = "rockchip,rk3368-gmac", .data = &rk3368_gmac_data},
+	{ .compatible = "rockchip,rk3288-gmac", .data = &rk3288_ops },
+	{ .compatible = "rockchip,rk3368-gmac", .data = &rk3368_ops },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, rk_gmac_dwmac_match);
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next 15/17] stmmac: remove unused stmmac_of_data struct
  2015-07-28 22:08 [PATCH net-next 00/17] stmmac clean up for 4.3 part2 Joachim Eastwood
                   ` (12 preceding siblings ...)
  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 ` Joachim Eastwood
  2015-07-28 22:09 ` [PATCH net-next 16/17] stmmac: remove setup/free glue callbacks Joachim Eastwood
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 19+ messages in thread
From: Joachim Eastwood @ 2015-07-28 22:09 UTC (permalink / raw)
  To: peppe.cavallaro, davem; +Cc: Joachim Eastwood, netdev

As dwmac-* drivers that need OF match have been converted
to use their own internal OF match data structure this can
now be removed.

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
 Documentation/networking/stmmac.txt |  2 --
 include/linux/stmmac.h              | 18 ------------------
 2 files changed, 20 deletions(-)

diff --git a/Documentation/networking/stmmac.txt b/Documentation/networking/stmmac.txt
index 5fddefa69baf..de5c42342ec3 100644
--- a/Documentation/networking/stmmac.txt
+++ b/Documentation/networking/stmmac.txt
@@ -274,8 +274,6 @@ capability register can replace what has been passed from the platform.
 Please see the following document:
 	Documentation/devicetree/bindings/net/stmmac.txt
 
-and the stmmac_of_data structure inside the include/linux/stmmac.h header file.
-
 4.11) This is a summary of the content of some relevant files:
  o stmmac_main.c: to implement the main network device driver;
  o stmmac_mdio.c: to provide mdio functions;
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index c86a20047cb1..b43cd56b78e9 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -125,22 +125,4 @@ struct plat_stmmacenet_data {
 	void (*exit)(struct platform_device *pdev, void *priv);
 	void *bsp_priv;
 };
-
-/* of_data for SoC glue layer device tree bindings */
-
-struct stmmac_of_data {
-	int has_gmac;
-	int enh_desc;
-	int tx_coe;
-	int rx_coe;
-	int bugged_jumbo;
-	int pmt;
-	int riwt_off;
-	void (*fix_mac_speed)(void *priv, unsigned int speed);
-	void (*bus_setup)(void __iomem *ioaddr);
-	void *(*setup)(struct platform_device *pdev);
-	void (*free)(struct platform_device *pdev, void *priv);
-	int (*init)(struct platform_device *pdev, void *priv);
-	void (*exit)(struct platform_device *pdev, void *priv);
-};
 #endif
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next 16/17] stmmac: remove setup/free glue callbacks
  2015-07-28 22:08 [PATCH net-next 00/17] stmmac clean up for 4.3 part2 Joachim Eastwood
                   ` (13 preceding siblings ...)
  2015-07-28 22:09 ` [PATCH net-next 15/17] stmmac: remove unused stmmac_of_data struct Joachim Eastwood
@ 2015-07-28 22:09 ` 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
  16 siblings, 0 replies; 19+ messages in thread
From: Joachim Eastwood @ 2015-07-28 22:09 UTC (permalink / raw)
  To: peppe.cavallaro, davem; +Cc: Joachim Eastwood, netdev

As all dwmac-* drivers have been converted to have a proper probe
function the setup callback can now be removed. Also remove the
free callback that wasn't used by any driver.

New dwmac-* drivers should implement standard probe and remove
functions to preform any needed setup and teardown.

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
 Documentation/networking/stmmac.txt                   | 8 ++------
 drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c   | 7 -------
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 3 ---
 include/linux/stmmac.h                                | 2 --
 4 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/Documentation/networking/stmmac.txt b/Documentation/networking/stmmac.txt
index de5c42342ec3..2903b1cf4d70 100644
--- a/Documentation/networking/stmmac.txt
+++ b/Documentation/networking/stmmac.txt
@@ -135,8 +135,6 @@ struct plat_stmmacenet_data {
 	int maxmtu;
 	void (*fix_mac_speed)(void *priv, unsigned int speed);
 	void (*bus_setup)(void __iomem *ioaddr);
-	void *(*setup)(struct platform_device *pdev);
-	void (*free)(struct platform_device *pdev, void *priv);
 	int (*init)(struct platform_device *pdev, void *priv);
 	void (*exit)(struct platform_device *pdev, void *priv);
 	void *bsp_priv;
@@ -177,12 +175,10 @@ Where:
  o bus_setup: perform HW setup of the bus. For example, on some ST platforms
 	     this field is used to configure the AMBA  bridge to generate more
 	     efficient STBus traffic.
- o setup/init/exit: callbacks used for calling a custom initialization;
+ o init/exit: callbacks used for calling a custom initialization;
 	     this is sometime necessary on some platforms (e.g. ST boxes)
 	     where the HW needs to have set some PIO lines or system cfg
-	     registers. setup should return a pointer to private data,
-	     which will be stored in bsp_priv, and then passed to init and
-	     exit callbacks. init/exit callbacks should not use or modify
+	     registers.  init/exit callbacks should not use or modify
 	     platform data.
  o bsp_priv: another private pointer.
 
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c
index f4fe9f1a33b4..b1e5f24708c9 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c
@@ -46,13 +46,6 @@ static int dwmac_generic_probe(struct platform_device *pdev)
 		plat_dat->unicast_filter_entries = 1;
 	}
 
-	/* Custom setup (if needed) */
-	if (plat_dat->setup) {
-		plat_dat->bsp_priv = plat_dat->setup(pdev);
-		if (IS_ERR(plat_dat->bsp_priv))
-			return PTR_ERR(plat_dat->bsp_priv);
-	}
-
 	/* Custom initialisation (if needed) */
 	if (plat_dat->init) {
 		ret = plat_dat->init(pdev, plat_dat->bsp_priv);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 55e569b330b2..1cb660405f35 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -300,9 +300,6 @@ int stmmac_pltfr_remove(struct platform_device *pdev)
 	if (priv->plat->exit)
 		priv->plat->exit(pdev, priv->plat->bsp_priv);
 
-	if (priv->plat->free)
-		priv->plat->free(pdev, priv->plat->bsp_priv);
-
 	return ret;
 }
 EXPORT_SYMBOL_GPL(stmmac_pltfr_remove);
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index b43cd56b78e9..eead8ab93c0a 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -119,8 +119,6 @@ struct plat_stmmacenet_data {
 	int rx_fifo_size;
 	void (*fix_mac_speed)(void *priv, unsigned int speed);
 	void (*bus_setup)(void __iomem *ioaddr);
-	void *(*setup)(struct platform_device *pdev);
-	void (*free)(struct platform_device *pdev, void *priv);
 	int (*init)(struct platform_device *pdev, void *priv);
 	void (*exit)(struct platform_device *pdev, void *priv);
 	void *bsp_priv;
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next 17/17] stmmac: dwmac-sti: refactor the init glue callbacks
  2015-07-28 22:08 [PATCH net-next 00/17] stmmac clean up for 4.3 part2 Joachim Eastwood
                   ` (14 preceding siblings ...)
  2015-07-28 22:09 ` [PATCH net-next 16/17] stmmac: remove setup/free glue callbacks Joachim Eastwood
@ 2015-07-28 22:09 ` Joachim Eastwood
  2015-07-29  7:13 ` [PATCH net-next 00/17] stmmac clean up for 4.3 part2 David Miller
  16 siblings, 0 replies; 19+ messages in thread
From: Joachim Eastwood @ 2015-07-28 22:09 UTC (permalink / raw)
  To: peppe.cavallaro, srinivas.kandagatla, davem
  Cc: Joachim Eastwood, netdev, kernel

Remove the two platform specific init callbacks and make
them use a common one by creating a function member in
the internal data structure. This allow us to remove the
layer of indirection and simplify the code a bit.

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c | 43 +++++++------------------
 1 file changed, 12 insertions(+), 31 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
index 83c501edb688..7f6f4a4fcc70 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
@@ -129,11 +129,11 @@ struct sti_dwmac {
 	struct device *dev;
 	struct regmap *regmap;
 	u32 speed;
+	void (*fix_retime_src)(void *priv, unsigned int speed);
 };
 
 struct sti_dwmac_of_data {
-	void (*fix_mac_speed)(void *priv, unsigned int speed);
-	int (*init)(struct platform_device *pdev, void *priv);
+	void (*fix_retime_src)(void *priv, unsigned int speed);
 };
 
 static u32 phy_intf_sels[] = {
@@ -228,8 +228,9 @@ static void stid127_fix_retime_src(void *priv, u32 spd)
 	regmap_update_bits(dwmac->regmap, reg, STID127_RETIME_SRC_MASK, val);
 }
 
-static void sti_dwmac_ctrl_init(struct sti_dwmac *dwmac)
+static int sti_dwmac_init(struct platform_device *pdev, void *priv)
 {
+	struct sti_dwmac *dwmac = priv;
 	struct regmap *regmap = dwmac->regmap;
 	int iface = dwmac->interface;
 	struct device *dev = dwmac->dev;
@@ -247,28 +248,8 @@ static void sti_dwmac_ctrl_init(struct sti_dwmac *dwmac)
 
 	val = (iface == PHY_INTERFACE_MODE_REVMII) ? 0 : ENMII;
 	regmap_update_bits(regmap, reg, ENMII_MASK, val);
-}
-
-static int stix4xx_init(struct platform_device *pdev, void *priv)
-{
-	struct sti_dwmac *dwmac = priv;
-	u32 spd = dwmac->speed;
-
-	sti_dwmac_ctrl_init(dwmac);
 
-	stih4xx_fix_retime_src(priv, spd);
-
-	return 0;
-}
-
-static int stid127_init(struct platform_device *pdev, void *priv)
-{
-	struct sti_dwmac *dwmac = priv;
-	u32 spd = dwmac->speed;
-
-	sti_dwmac_ctrl_init(dwmac);
-
-	stid127_fix_retime_src(priv, spd);
+	dwmac->fix_retime_src(priv, dwmac->speed);
 
 	return 0;
 }
@@ -372,12 +353,14 @@ static int sti_dwmac_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	dwmac->fix_retime_src = data->fix_retime_src;
+
 	plat_dat->bsp_priv = dwmac;
-	plat_dat->init = data->init;
+	plat_dat->init = sti_dwmac_init;
 	plat_dat->exit = sti_dwmac_exit;
-	plat_dat->fix_mac_speed = data->fix_mac_speed;
+	plat_dat->fix_mac_speed = data->fix_retime_src;
 
-	ret = plat_dat->init(pdev, plat_dat->bsp_priv);
+	ret = sti_dwmac_init(pdev, plat_dat->bsp_priv);
 	if (ret)
 		return ret;
 
@@ -385,13 +368,11 @@ static int sti_dwmac_probe(struct platform_device *pdev)
 }
 
 static const struct sti_dwmac_of_data stih4xx_dwmac_data = {
-	.fix_mac_speed = stih4xx_fix_retime_src,
-	.init = stix4xx_init,
+	.fix_retime_src = stih4xx_fix_retime_src,
 };
 
 static const struct sti_dwmac_of_data stid127_dwmac_data = {
-	.fix_mac_speed = stid127_fix_retime_src,
-	.init = stid127_init,
+	.fix_retime_src = stid127_fix_retime_src,
 };
 
 static const struct of_device_id sti_dwmac_match[] = {
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH net-next 00/17] stmmac clean up for 4.3 part2
  2015-07-28 22:08 [PATCH net-next 00/17] stmmac clean up for 4.3 part2 Joachim Eastwood
                   ` (15 preceding siblings ...)
  2015-07-28 22:09 ` [PATCH net-next 17/17] stmmac: dwmac-sti: refactor the init " Joachim Eastwood
@ 2015-07-29  7:13 ` David Miller
  16 siblings, 0 replies; 19+ messages in thread
From: David Miller @ 2015-07-29  7:13 UTC (permalink / raw)
  To: manabian
  Cc: peppe.cavallaro, netdev, b.galvani, arnd, roger.chen, heiko,
	wens, dinguyen, linux-rockchip, mathieu

From: Joachim Eastwood <manabian@gmail.com>
Date: Wed, 29 Jul 2015 00:08:47 +0200

> This patch set creates proper probe functions in the remaining
> dwmac-* drivers, lets the drivers manage their own of match data
> structure, and cleans up some of the drivers a bit. Note that
> should be no functional change in any of the drivers.

This is a really nice set of simplifications, series applied, thanks.

Please follow up on any breakage reported, thanks.

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2015-07-29  7:13 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH net-next 03/17] stmmac: dwmac-ipq806x: turn setup callback into a probe function Joachim Eastwood
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).