netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/8] stmmac clean up for 4.3 part1
@ 2015-07-16 22:26 Joachim Eastwood
  2015-07-16 22:26 ` [PATCH net-next 1/8] stmmac: use of_device_get_match_data to retrieve of match data Joachim Eastwood
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Joachim Eastwood @ 2015-07-16 22:26 UTC (permalink / raw)
  To: peppe.cavallaro, davem, arnd, b.galvani; +Cc: Joachim Eastwood, netdev

Hi everyone,

This patch set continues the conversion of the dwmac glue layers
to more proper platform drivers. The first part of the patch set
cleans up stmmac_platform a bit. Refactors code from the common
probe function and exports two functions that will be used in
the dwmac-* drivers.

Second part converts two simple dwmac-* drivers to have their
own probe function and use the exported functions. This brings
us closer to point where stmmac_platform is only a library of
common functions for the dwmac-* drivers to use.

The plan next is:
 * add probe functions to the rest of the dwmac-* drivers
 * move probe function in stmmac_platform to dwmac-generic
 * remove struct stmmac_of_data and let those drivers
   that actually need match data handle it themselves
 * clean up include/linux/stmmac.h

Note that this patch set has only been tested on lpc18xx so
testing on other platforms is greatly appreciated.

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

Joachim Eastwood (8):
  stmmac: use of_device_get_match_data to retrieve of match data
  stmmac: clean up platform/of_match data retrieval
  stmmac: introduce stmmac_get_platform_resources()
  stmmac: make stmmac_probe_config_dt return the platform data struct
  stmmac: export probe_config_dt() and get_platform_resources()
  stmmac: add proper probe function to dwmac-lpc18xx
  stmmac: add proper probe function to dwmac-meson
  stmmac: drop custom_* fields from plat_stmmacenet_data

 Documentation/networking/stmmac.txt                |   4 -
 .../net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c    |  59 ++++-----
 drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c  |  31 +++--
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  | 136 ++++++++++++---------
 .../net/ethernet/stmicro/stmmac/stmmac_platform.h  |   8 ++
 include/linux/stmmac.h                             |   2 -
 6 files changed, 126 insertions(+), 114 deletions(-)

-- 
1.8.0

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

* [PATCH net-next 1/8] stmmac: use of_device_get_match_data to retrieve of match data
  2015-07-16 22:26 [PATCH net-next 0/8] stmmac clean up for 4.3 part1 Joachim Eastwood
@ 2015-07-16 22:26 ` Joachim Eastwood
  2015-07-16 22:26 ` [PATCH net-next 2/8] stmmac: clean up platform/of_match data retrieval Joachim Eastwood
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Joachim Eastwood @ 2015-07-16 22:26 UTC (permalink / raw)
  To: peppe.cavallaro, davem; +Cc: Joachim Eastwood, netdev

By using of_device_get_match_data() the code that retrieve
match data can be simplified quite a bit.

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

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index f3918c7e7eeb..89e40ddc0391 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -109,13 +109,11 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
 				  const char **mac)
 {
 	struct device_node *np = pdev->dev.of_node;
+	const struct stmmac_of_data *data;
 	struct stmmac_dma_cfg *dma_cfg;
-	const struct of_device_id *device;
-	struct device *dev = &pdev->dev;
 
-	device = of_match_device(dev->driver->of_match_table, dev);
-	if (device->data) {
-		const struct stmmac_of_data *data = device->data;
+	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;
-- 
1.8.0

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

* [PATCH net-next 2/8] stmmac: clean up platform/of_match data retrieval
  2015-07-16 22:26 [PATCH net-next 0/8] stmmac clean up for 4.3 part1 Joachim Eastwood
  2015-07-16 22:26 ` [PATCH net-next 1/8] stmmac: use of_device_get_match_data to retrieve of match data Joachim Eastwood
@ 2015-07-16 22:26 ` Joachim Eastwood
  2015-07-16 22:26 ` [PATCH net-next 3/8] stmmac: introduce stmmac_get_platform_resources() Joachim Eastwood
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Joachim Eastwood @ 2015-07-16 22:26 UTC (permalink / raw)
  To: peppe.cavallaro, davem; +Cc: Joachim Eastwood, netdev

Refactor code to clearly separate probing non-dt versus dt. In the
non-dt case platform data must be supplied to probe successfully.
For dt the platform data structure is created and match data is
copied into it. Note that support for supplying platform data in
dt from AUXDATA is dropped as no users in mainline does this.

This change will allow dt dwmac-* drivers to call the config_dt()
function from probe to create the needed platform data struct and
retrieve common dt properties.

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

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 89e40ddc0391..6e6ef859f58a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -105,13 +105,20 @@ static int dwmac1000_validate_ucast_entries(int ucast_entries)
  * set some private fields that will be used by the main at runtime.
  */
 static int stmmac_probe_config_dt(struct platform_device *pdev,
-				  struct plat_stmmacenet_data *plat,
+				  struct plat_stmmacenet_data **plat_dat,
 				  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 -ENOMEM;
+
+	*plat_dat = plat;
+
 	data = of_device_get_match_data(&pdev->dev);
 	if (data) {
 		plat->has_gmac = data->has_gmac;
@@ -180,6 +187,12 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
 	 */
 	plat->maxmtu = JUMBO_LEN;
 
+	/* Set default value for multicast hash bins */
+	plat->multicast_filter_bins = HASH_TABLE_SIZE;
+
+	/* Set default value for unicast filter entries */
+	plat->unicast_filter_entries = 1;
+
 	/*
 	 * Currently only the properties needed on SPEAr600
 	 * are provided. All other properties should be added
@@ -242,7 +255,7 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
 }
 #else
 static int stmmac_probe_config_dt(struct platform_device *pdev,
-				  struct plat_stmmacenet_data *plat,
+				  struct plat_stmmacenet_data **plat,
 				  const char **mac)
 {
 	return -ENOSYS;
@@ -301,29 +314,24 @@ int stmmac_pltfr_probe(struct platform_device *pdev)
 	if (IS_ERR(stmmac_res.addr))
 		return PTR_ERR(stmmac_res.addr);
 
-	plat_dat = dev_get_platdata(&pdev->dev);
-
-	if (!plat_dat)
-		plat_dat = devm_kzalloc(&pdev->dev,
-					sizeof(struct plat_stmmacenet_data),
-					GFP_KERNEL);
-	if (!plat_dat) {
-		pr_err("%s: ERROR: no memory", __func__);
-		return  -ENOMEM;
-	}
-
-	/* 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;
-
 	if (pdev->dev.of_node) {
-		ret = stmmac_probe_config_dt(pdev, plat_dat, &stmmac_res.mac);
+		ret = stmmac_probe_config_dt(pdev, &plat_dat, &stmmac_res.mac);
 		if (ret) {
-			pr_err("%s: main dt probe failed", __func__);
+			dev_err(&pdev->dev, "dt configuration failed\n");
 			return ret;
 		}
+	} 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) */
-- 
1.8.0

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

* [PATCH net-next 3/8] stmmac: introduce stmmac_get_platform_resources()
  2015-07-16 22:26 [PATCH net-next 0/8] stmmac clean up for 4.3 part1 Joachim Eastwood
  2015-07-16 22:26 ` [PATCH net-next 1/8] stmmac: use of_device_get_match_data to retrieve of match data Joachim Eastwood
  2015-07-16 22:26 ` [PATCH net-next 2/8] stmmac: clean up platform/of_match data retrieval Joachim Eastwood
@ 2015-07-16 22:26 ` Joachim Eastwood
  2015-07-16 22:26 ` [PATCH net-next 4/8] stmmac: make stmmac_probe_config_dt return the platform data struct Joachim Eastwood
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Joachim Eastwood @ 2015-07-16 22:26 UTC (permalink / raw)
  To: peppe.cavallaro, davem; +Cc: Joachim Eastwood, netdev

Refactor all code that deals with platform resources into it's
own get function. This function will later be used in the probe
function in dwmac-* drivers.

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  | 64 +++++++++++++---------
 1 file changed, 37 insertions(+), 27 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 6e6ef859f58a..94962d75b99a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -262,33 +262,23 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
 }
 #endif /* CONFIG_OF */
 
-/**
- * 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)
+static int stmmac_get_platform_resources(struct platform_device *pdev,
+					 struct stmmac_resources *stmmac_res)
 {
-	struct stmmac_resources stmmac_res;
-	int ret = 0;
 	struct resource *res;
-	struct device *dev = &pdev->dev;
-	struct plat_stmmacenet_data *plat_dat = NULL;
 
-	memset(&stmmac_res, 0, sizeof(stmmac_res));
+	memset(stmmac_res, 0, sizeof(*stmmac_res));
 
 	/* Get IRQ information early to have an ability to ask for deferred
 	 * probe if needed before we went too far with resource allocation.
 	 */
-	stmmac_res.irq = platform_get_irq_byname(pdev, "macirq");
-	if (stmmac_res.irq < 0) {
-		if (stmmac_res.irq != -EPROBE_DEFER) {
-			dev_err(dev,
+	stmmac_res->irq = platform_get_irq_byname(pdev, "macirq");
+	if (stmmac_res->irq < 0) {
+		if (stmmac_res->irq != -EPROBE_DEFER) {
+			dev_err(&pdev->dev,
 				"MAC IRQ configuration information not found\n");
 		}
-		return stmmac_res.irq;
+		return stmmac_res->irq;
 	}
 
 	/* On some platforms e.g. SPEAr the wake up irq differs from the mac irq
@@ -298,21 +288,41 @@ int stmmac_pltfr_probe(struct platform_device *pdev)
 	 * In case the wake up interrupt is not passed from the platform
 	 * so the driver will continue to use the mac irq (ndev->irq)
 	 */
-	stmmac_res.wol_irq = platform_get_irq_byname(pdev, "eth_wake_irq");
-	if (stmmac_res.wol_irq < 0) {
-		if (stmmac_res.wol_irq == -EPROBE_DEFER)
+	stmmac_res->wol_irq = platform_get_irq_byname(pdev, "eth_wake_irq");
+	if (stmmac_res->wol_irq < 0) {
+		if (stmmac_res->wol_irq == -EPROBE_DEFER)
 			return -EPROBE_DEFER;
-		stmmac_res.wol_irq = stmmac_res.irq;
+		stmmac_res->wol_irq = stmmac_res->irq;
 	}
 
-	stmmac_res.lpi_irq = platform_get_irq_byname(pdev, "eth_lpi");
-	if (stmmac_res.lpi_irq == -EPROBE_DEFER)
+	stmmac_res->lpi_irq = platform_get_irq_byname(pdev, "eth_lpi");
+	if (stmmac_res->lpi_irq == -EPROBE_DEFER)
 		return -EPROBE_DEFER;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	stmmac_res.addr = devm_ioremap_resource(dev, res);
-	if (IS_ERR(stmmac_res.addr))
-		return PTR_ERR(stmmac_res.addr);
+	stmmac_res->addr = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(stmmac_res->addr))
+		return PTR_ERR(stmmac_res->addr);
+
+	return 0;
+}
+
+/**
+ * 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) {
 		ret = stmmac_probe_config_dt(pdev, &plat_dat, &stmmac_res.mac);
-- 
1.8.0

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

* [PATCH net-next 4/8] stmmac: make stmmac_probe_config_dt return the platform data struct
  2015-07-16 22:26 [PATCH net-next 0/8] stmmac clean up for 4.3 part1 Joachim Eastwood
                   ` (2 preceding siblings ...)
  2015-07-16 22:26 ` [PATCH net-next 3/8] stmmac: introduce stmmac_get_platform_resources() Joachim Eastwood
@ 2015-07-16 22:26 ` Joachim Eastwood
  2015-07-16 22:26 ` [PATCH net-next 5/8] stmmac: export probe_config_dt() and get_platform_resources() Joachim Eastwood
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Joachim Eastwood @ 2015-07-16 22:26 UTC (permalink / raw)
  To: peppe.cavallaro, davem; +Cc: Joachim Eastwood, netdev

Since stmmac_probe_config_dt() allocates the platform data structure
it is cleaner if it just returned this structure directly. This
function will later be used in the probe function in dwmac-* drivers.

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  | 28 ++++++++++------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 94962d75b99a..ea467be93673 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -104,9 +104,8 @@ static int dwmac1000_validate_ucast_entries(int ucast_entries)
  * this function is to read the driver parameters from device-tree and
  * set some private fields that will be used by the main at runtime.
  */
-static int stmmac_probe_config_dt(struct platform_device *pdev,
-				  struct plat_stmmacenet_data **plat_dat,
-				  const char **mac)
+static struct plat_stmmacenet_data *
+stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 {
 	struct device_node *np = pdev->dev.of_node;
 	struct plat_stmmacenet_data *plat;
@@ -115,9 +114,7 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
 
 	plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
 	if (!plat)
-		return -ENOMEM;
-
-	*plat_dat = plat;
+		return ERR_PTR(-ENOMEM);
 
 	data = of_device_get_match_data(&pdev->dev);
 	if (data) {
@@ -156,7 +153,7 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
 	/* If phy-handle is not specified, check if we have a fixed-phy */
 	if (!plat->phy_node && of_phy_is_fixed_link(np)) {
 		if ((of_phy_register_fixed_link(np) < 0))
-			return -ENODEV;
+			return ERR_PTR(-ENODEV);
 
 		plat->phy_node = of_node_get(np);
 	}
@@ -233,7 +230,7 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
 				       GFP_KERNEL);
 		if (!dma_cfg) {
 			of_node_put(np);
-			return -ENOMEM;
+			return ERR_PTR(-ENOMEM);
 		}
 		plat->dma_cfg = dma_cfg;
 		of_property_read_u32(np, "snps,pbl", &dma_cfg->pbl);
@@ -251,14 +248,13 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
 		pr_warn("force_sf_dma_mode is ignored if force_thresh_dma_mode is set.");
 	}
 
-	return 0;
+	return plat;
 }
 #else
-static int stmmac_probe_config_dt(struct platform_device *pdev,
-				  struct plat_stmmacenet_data **plat,
-				  const char **mac)
+static struct plat_stmmacenet_data *
+stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 {
-	return -ENOSYS;
+	return ERR_PTR(-ENOSYS);
 }
 #endif /* CONFIG_OF */
 
@@ -325,10 +321,10 @@ int stmmac_pltfr_probe(struct platform_device *pdev)
 		return ret;
 
 	if (pdev->dev.of_node) {
-		ret = stmmac_probe_config_dt(pdev, &plat_dat, &stmmac_res.mac);
-		if (ret) {
+		plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac);
+		if (IS_ERR(plat_dat)) {
 			dev_err(&pdev->dev, "dt configuration failed\n");
-			return ret;
+			return PTR_ERR(plat_dat);
 		}
 	} else {
 		plat_dat = dev_get_platdata(&pdev->dev);
-- 
1.8.0

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

* [PATCH net-next 5/8] stmmac: export probe_config_dt() and get_platform_resources()
  2015-07-16 22:26 [PATCH net-next 0/8] stmmac clean up for 4.3 part1 Joachim Eastwood
                   ` (3 preceding siblings ...)
  2015-07-16 22:26 ` [PATCH net-next 4/8] stmmac: make stmmac_probe_config_dt return the platform data struct Joachim Eastwood
@ 2015-07-16 22:26 ` Joachim Eastwood
  2015-07-16 22:26 ` [PATCH net-next 6/8] stmmac: add proper probe function to dwmac-lpc18xx Joachim Eastwood
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Joachim Eastwood @ 2015-07-16 22:26 UTC (permalink / raw)
  To: peppe.cavallaro, davem; +Cc: Joachim Eastwood, netdev

Export stmmac_probe_config_dt() and stmmac_get_platform_resources()
so they can be used in the dwmac-* drivers themselves. This will
allow us to build more flexible and standalone drivers which just
use stmmac_platform as a library for setup functions.

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 10 ++++++----
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h |  8 ++++++++
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index ea467be93673..eca0eb845241 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -104,7 +104,7 @@ static int dwmac1000_validate_ucast_entries(int ucast_entries)
  * this function is to read the driver parameters from device-tree and
  * set some private fields that will be used by the main at runtime.
  */
-static struct plat_stmmacenet_data *
+struct plat_stmmacenet_data *
 stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 {
 	struct device_node *np = pdev->dev.of_node;
@@ -251,15 +251,16 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 	return plat;
 }
 #else
-static struct plat_stmmacenet_data *
+struct plat_stmmacenet_data *
 stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 {
 	return ERR_PTR(-ENOSYS);
 }
 #endif /* CONFIG_OF */
+EXPORT_SYMBOL_GPL(stmmac_probe_config_dt);
 
-static int stmmac_get_platform_resources(struct platform_device *pdev,
-					 struct stmmac_resources *stmmac_res)
+int stmmac_get_platform_resources(struct platform_device *pdev,
+				  struct stmmac_resources *stmmac_res)
 {
 	struct resource *res;
 
@@ -302,6 +303,7 @@ static int stmmac_get_platform_resources(struct platform_device *pdev,
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(stmmac_get_platform_resources);
 
 /**
  * stmmac_pltfr_probe - platform driver probe.
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h
index 71da86d7bd00..84ceb5342686 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h
@@ -19,6 +19,14 @@
 #ifndef __STMMAC_PLATFORM_H__
 #define __STMMAC_PLATFORM_H__
 
+#include "stmmac.h"
+
+struct plat_stmmacenet_data *
+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] 10+ messages in thread

* [PATCH net-next 6/8] stmmac: add proper probe function to dwmac-lpc18xx
  2015-07-16 22:26 [PATCH net-next 0/8] stmmac clean up for 4.3 part1 Joachim Eastwood
                   ` (4 preceding siblings ...)
  2015-07-16 22:26 ` [PATCH net-next 5/8] stmmac: export probe_config_dt() and get_platform_resources() Joachim Eastwood
@ 2015-07-16 22:26 ` Joachim Eastwood
  2015-07-16 22:26 ` [PATCH net-next 7/8] stmmac: add proper probe function to dwmac-meson Joachim Eastwood
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Joachim Eastwood @ 2015-07-16 22:26 UTC (permalink / raw)
  To: peppe.cavallaro, davem; +Cc: Joachim Eastwood, netdev

By using a few functions from stmmac_platform we can now create
a proper probe function in this driver. By doing so we can drop
the OF match data and simplify the overall driver.

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

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c
index cb888d3ebbdc..78e9d1861896 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c
@@ -25,66 +25,53 @@
 # define LPC18XX_CREG_CREG6_ETHMODE_MII		0x0
 # define LPC18XX_CREG_CREG6_ETHMODE_RMII	0x4
 
-struct lpc18xx_dwmac_priv_data {
+static int lpc18xx_dwmac_probe(struct platform_device *pdev)
+{
+	struct plat_stmmacenet_data *plat_dat;
+	struct stmmac_resources stmmac_res;
 	struct regmap *reg;
-	int interface;
-};
+	u8 ethmode;
+	int ret;
 
-static void *lpc18xx_dwmac_setup(struct platform_device *pdev)
-{
-	struct lpc18xx_dwmac_priv_data *dwmac;
+	ret = stmmac_get_platform_resources(pdev, &stmmac_res);
+	if (ret)
+		return ret;
 
-	dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
-	if (!dwmac)
-		return ERR_PTR(-ENOMEM);
+	plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac);
+	if (IS_ERR(plat_dat))
+		return PTR_ERR(plat_dat);
 
-	dwmac->interface = of_get_phy_mode(pdev->dev.of_node);
-	if (dwmac->interface < 0)
-		return ERR_PTR(dwmac->interface);
+	plat_dat->has_gmac = true;
 
-	dwmac->reg = syscon_regmap_lookup_by_compatible("nxp,lpc1850-creg");
-	if (IS_ERR(dwmac->reg)) {
-		dev_err(&pdev->dev, "Syscon lookup failed\n");
-		return dwmac->reg;
+	reg = syscon_regmap_lookup_by_compatible("nxp,lpc1850-creg");
+	if (IS_ERR(reg)) {
+		dev_err(&pdev->dev, "syscon lookup failed\n");
+		return PTR_ERR(reg);
 	}
 
-	return dwmac;
-}
-
-static int lpc18xx_dwmac_init(struct platform_device *pdev, void *priv)
-{
-	struct lpc18xx_dwmac_priv_data *dwmac = priv;
-	u8 ethmode;
-
-	if (dwmac->interface == PHY_INTERFACE_MODE_MII) {
+	if (plat_dat->interface == PHY_INTERFACE_MODE_MII) {
 		ethmode = LPC18XX_CREG_CREG6_ETHMODE_MII;
-	} else if (dwmac->interface == PHY_INTERFACE_MODE_RMII) {
+	} else if (plat_dat->interface == PHY_INTERFACE_MODE_RMII) {
 		ethmode = LPC18XX_CREG_CREG6_ETHMODE_RMII;
 	} else {
 		dev_err(&pdev->dev, "Only MII and RMII mode supported\n");
 		return -EINVAL;
 	}
 
-	regmap_update_bits(dwmac->reg, LPC18XX_CREG_CREG6,
+	regmap_update_bits(reg, LPC18XX_CREG_CREG6,
 			   LPC18XX_CREG_CREG6_ETHMODE_MASK, ethmode);
 
-	return 0;
+	return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
 }
 
-static const struct stmmac_of_data lpc18xx_dwmac_data = {
-	.has_gmac = 1,
-	.setup = lpc18xx_dwmac_setup,
-	.init = lpc18xx_dwmac_init,
-};
-
 static const struct of_device_id lpc18xx_dwmac_match[] = {
-	{ .compatible = "nxp,lpc1850-dwmac", .data = &lpc18xx_dwmac_data },
+	{ .compatible = "nxp,lpc1850-dwmac" },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, lpc18xx_dwmac_match);
 
 static struct platform_driver lpc18xx_dwmac_driver = {
-	.probe  = stmmac_pltfr_probe,
+	.probe  = lpc18xx_dwmac_probe,
 	.remove = stmmac_pltfr_remove,
 	.driver = {
 		.name           = "lpc18xx-dwmac",
-- 
1.8.0

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

* [PATCH net-next 7/8] stmmac: add proper probe function to dwmac-meson
  2015-07-16 22:26 [PATCH net-next 0/8] stmmac clean up for 4.3 part1 Joachim Eastwood
                   ` (5 preceding siblings ...)
  2015-07-16 22:26 ` [PATCH net-next 6/8] stmmac: add proper probe function to dwmac-lpc18xx Joachim Eastwood
@ 2015-07-16 22:26 ` Joachim Eastwood
  2015-07-16 22:26 ` [PATCH net-next 8/8] stmmac: drop custom_* fields from plat_stmmacenet_data Joachim Eastwood
  2015-07-21  3:46 ` [PATCH net-next 0/8] stmmac clean up for 4.3 part1 David Miller
  8 siblings, 0 replies; 10+ messages in thread
From: Joachim Eastwood @ 2015-07-16 22:26 UTC (permalink / raw)
  To: peppe.cavallaro, davem, b.galvani; +Cc: Joachim Eastwood, netdev

By using a few functions from stmmac_platform we can now create
a proper probe function in this driver. By doing so we can drop
the OF match data and simplify the overall driver.

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

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c
index 61a324a87d09..c1bac1912b37 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c
@@ -47,36 +47,45 @@ static void meson6_dwmac_fix_mac_speed(void *priv, unsigned int speed)
 	writel(val, dwmac->reg);
 }
 
-static void *meson6_dwmac_setup(struct platform_device *pdev)
+static int meson6_dwmac_probe(struct platform_device *pdev)
 {
+	struct plat_stmmacenet_data *plat_dat;
+	struct stmmac_resources stmmac_res;
 	struct meson_dwmac *dwmac;
 	struct resource *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);
 
 	dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
 	if (!dwmac)
-		return ERR_PTR(-ENOMEM);
+		return -ENOMEM;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
 	dwmac->reg = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(dwmac->reg))
-		return ERR_CAST(dwmac->reg);
+		return PTR_ERR(dwmac->reg);
 
-	return dwmac;
-}
+	plat_dat->bsp_priv = dwmac;
+	plat_dat->fix_mac_speed = meson6_dwmac_fix_mac_speed;
 
-static const struct stmmac_of_data meson6_dwmac_data = {
-	.setup		= meson6_dwmac_setup,
-	.fix_mac_speed	= meson6_dwmac_fix_mac_speed,
-};
+	return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
+}
 
 static const struct of_device_id meson6_dwmac_match[] = {
-	{ .compatible = "amlogic,meson6-dwmac", .data = &meson6_dwmac_data},
+	{ .compatible = "amlogic,meson6-dwmac" },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, meson6_dwmac_match);
 
 static struct platform_driver meson6_dwmac_driver = {
-	.probe  = stmmac_pltfr_probe,
+	.probe  = meson6_dwmac_probe,
 	.remove = stmmac_pltfr_remove,
 	.driver = {
 		.name           = "meson6-dwmac",
-- 
1.8.0

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

* [PATCH net-next 8/8] stmmac: drop custom_* fields from plat_stmmacenet_data
  2015-07-16 22:26 [PATCH net-next 0/8] stmmac clean up for 4.3 part1 Joachim Eastwood
                   ` (6 preceding siblings ...)
  2015-07-16 22:26 ` [PATCH net-next 7/8] stmmac: add proper probe function to dwmac-meson Joachim Eastwood
@ 2015-07-16 22:26 ` Joachim Eastwood
  2015-07-21  3:46 ` [PATCH net-next 0/8] stmmac clean up for 4.3 part1 David Miller
  8 siblings, 0 replies; 10+ messages in thread
From: Joachim Eastwood @ 2015-07-16 22:26 UTC (permalink / raw)
  To: peppe.cavallaro, davem; +Cc: Joachim Eastwood, netdev

Both of these fields are unused and has been unused since they
were added 3 and 5 years ago. Drop them since they are clearly
not very useful.

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

diff --git a/Documentation/networking/stmmac.txt b/Documentation/networking/stmmac.txt
index e655e2453c98..5fddefa69baf 100644
--- a/Documentation/networking/stmmac.txt
+++ b/Documentation/networking/stmmac.txt
@@ -139,8 +139,6 @@ struct plat_stmmacenet_data {
 	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 *custom_cfg;
-	void *custom_data;
 	void *bsp_priv;
 };
 
@@ -186,8 +184,6 @@ Where:
 	     which will be stored in bsp_priv, and then passed to init and
 	     exit callbacks. init/exit callbacks should not use or modify
 	     platform data.
- o custom_cfg/custom_data: this is a custom configuration that can be passed
-			   while initializing the resources.
  o bsp_priv: another private pointer.
 
 For MDIO bus The we have:
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index c735f5c91eea..c86a20047cb1 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -123,8 +123,6 @@ struct plat_stmmacenet_data {
 	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 *custom_cfg;
-	void *custom_data;
 	void *bsp_priv;
 };
 
-- 
1.8.0

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

* Re: [PATCH net-next 0/8] stmmac clean up for 4.3 part1
  2015-07-16 22:26 [PATCH net-next 0/8] stmmac clean up for 4.3 part1 Joachim Eastwood
                   ` (7 preceding siblings ...)
  2015-07-16 22:26 ` [PATCH net-next 8/8] stmmac: drop custom_* fields from plat_stmmacenet_data Joachim Eastwood
@ 2015-07-21  3:46 ` David Miller
  8 siblings, 0 replies; 10+ messages in thread
From: David Miller @ 2015-07-21  3:46 UTC (permalink / raw)
  To: manabian; +Cc: peppe.cavallaro, arnd, b.galvani, netdev

From: Joachim Eastwood <manabian@gmail.com>
Date: Fri, 17 Jul 2015 00:26:04 +0200

> This patch set continues the conversion of the dwmac glue layers
> to more proper platform drivers. The first part of the patch set
> cleans up stmmac_platform a bit. Refactors code from the common
> probe function and exports two functions that will be used in
> the dwmac-* drivers.
> 
> Second part converts two simple dwmac-* drivers to have their
> own probe function and use the exported functions. This brings
> us closer to point where stmmac_platform is only a library of
> common functions for the dwmac-* drivers to use.
> 
> The plan next is:
>  * add probe functions to the rest of the dwmac-* drivers
>  * move probe function in stmmac_platform to dwmac-generic
>  * remove struct stmmac_of_data and let those drivers
>    that actually need match data handle it themselves
>  * clean up include/linux/stmmac.h
> 
> Note that this patch set has only been tested on lpc18xx so
> testing on other platforms is greatly appreciated.
> 
> Previous parts can be found here:
> http://www.spinics.net/lists/netdev/msg328997.html
> http://www.spinics.net/lists/netdev/msg329932.html

Series applied, thanks.

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

end of thread, other threads:[~2015-07-21  3:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-16 22:26 [PATCH net-next 0/8] stmmac clean up for 4.3 part1 Joachim Eastwood
2015-07-16 22:26 ` [PATCH net-next 1/8] stmmac: use of_device_get_match_data to retrieve of match data Joachim Eastwood
2015-07-16 22:26 ` [PATCH net-next 2/8] stmmac: clean up platform/of_match data retrieval Joachim Eastwood
2015-07-16 22:26 ` [PATCH net-next 3/8] stmmac: introduce stmmac_get_platform_resources() Joachim Eastwood
2015-07-16 22:26 ` [PATCH net-next 4/8] stmmac: make stmmac_probe_config_dt return the platform data struct Joachim Eastwood
2015-07-16 22:26 ` [PATCH net-next 5/8] stmmac: export probe_config_dt() and get_platform_resources() Joachim Eastwood
2015-07-16 22:26 ` [PATCH net-next 6/8] stmmac: add proper probe function to dwmac-lpc18xx Joachim Eastwood
2015-07-16 22:26 ` [PATCH net-next 7/8] stmmac: add proper probe function to dwmac-meson Joachim Eastwood
2015-07-16 22:26 ` [PATCH net-next 8/8] stmmac: drop custom_* fields from plat_stmmacenet_data Joachim Eastwood
2015-07-21  3:46 ` [PATCH net-next 0/8] stmmac clean up for 4.3 part1 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).