Linux-Rockchip Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 00/17] stmmac clean up for 4.3 part2
@ 2015-07-28 22:08 Joachim Eastwood
       [not found] ` <1438121344-5304-1-git-send-email-manabian-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ 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] 5+ 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; 5+ 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] 5+ 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; 5+ 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] 5+ 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
       [not found] ` <1438121344-5304-1-git-send-email-manabian-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 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
  2 siblings, 0 replies; 5+ 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] 5+ 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
       [not found] ` <1438121344-5304-1-git-send-email-manabian-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  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-29  7:13 ` David Miller
  2 siblings, 0 replies; 5+ 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] 5+ messages in thread

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

Thread overview: 5+ 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
     [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-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