All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/4] introduce devm_mdiobus_alloc/free and clean up davinci mdio
@ 2014-04-30 12:23 ` Grygorii Strashko
  0 siblings, 0 replies; 13+ messages in thread
From: Grygorii Strashko @ 2014-04-30 12:23 UTC (permalink / raw)
  To: Florian Fainelli, netdev
  Cc: Randy Dunlap, Jonathan Cameron, David S. Miller,
	santosh.shilimkar, Sekhar Nori, linux-doc, linux-kernel,
	davinci-linux-open-source, sergei.shtylyov, prabhakar.csengg,
	Grygorii Strashko

Introduce a resource managed devm_mdiobus_alloc[_size]()/devm_mdiobus_free()
to automatically clean up MDIO bus alocations made by MDIO drivers,
thus leading to simplified MDIO drivers code.

Clean up Davinci MDIO driver and use new devm API.

Changes in v3:
- added devm_mdiobus_alloc_size() and
  devm_mdiobus_alloc() converted to be just a simple wrapper now.

Changes in v2:
- minor comments taken into account
- additional patches added for cleaning up Davinci MDIO driver

Cc: Florian Fainelli <f.fainelli@gmail.com>

Grygorii Strashko (4):
  mdio_bus: implement devm_mdiobus_alloc/devm_mdiobus_free
  net: davinci_mdio: use devm_* api
  net: davinci_mdio: drop pinctrl_pm_select_default_state from probe
  net: davinci_mdio: simplify IO memory mapping

 Documentation/driver-model/devres.txt  |    5 +++
 drivers/net/ethernet/ti/davinci_mdio.c |   48 ++++-------------------
 drivers/net/phy/mdio_bus.c             |   67 ++++++++++++++++++++++++++++++++
 include/linux/phy.h                    |    7 ++++
 4 files changed, 87 insertions(+), 40 deletions(-)

-- 
1.7.9.5


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

* [PATCH v3 0/4] introduce devm_mdiobus_alloc/free and clean up davinci mdio
@ 2014-04-30 12:23 ` Grygorii Strashko
  0 siblings, 0 replies; 13+ messages in thread
From: Grygorii Strashko @ 2014-04-30 12:23 UTC (permalink / raw)
  To: Florian Fainelli, netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/,
	linux-doc-u79uwXL29TY76Z2rM5mHXA, Randy Dunlap,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	santosh.shilimkar-l0cyMroinI0, David S. Miller, Jonathan Cameron

Introduce a resource managed devm_mdiobus_alloc[_size]()/devm_mdiobus_free()
to automatically clean up MDIO bus alocations made by MDIO drivers,
thus leading to simplified MDIO drivers code.

Clean up Davinci MDIO driver and use new devm API.

Changes in v3:
- added devm_mdiobus_alloc_size() and
  devm_mdiobus_alloc() converted to be just a simple wrapper now.

Changes in v2:
- minor comments taken into account
- additional patches added for cleaning up Davinci MDIO driver

Cc: Florian Fainelli <f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Grygorii Strashko (4):
  mdio_bus: implement devm_mdiobus_alloc/devm_mdiobus_free
  net: davinci_mdio: use devm_* api
  net: davinci_mdio: drop pinctrl_pm_select_default_state from probe
  net: davinci_mdio: simplify IO memory mapping

 Documentation/driver-model/devres.txt  |    5 +++
 drivers/net/ethernet/ti/davinci_mdio.c |   48 ++++-------------------
 drivers/net/phy/mdio_bus.c             |   67 ++++++++++++++++++++++++++++++++
 include/linux/phy.h                    |    7 ++++
 4 files changed, 87 insertions(+), 40 deletions(-)

-- 
1.7.9.5

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

* [PATCH v3 1/4] mdio_bus: implement devm_mdiobus_alloc/devm_mdiobus_free
@ 2014-04-30 12:23   ` Grygorii Strashko
  0 siblings, 0 replies; 13+ messages in thread
From: Grygorii Strashko @ 2014-04-30 12:23 UTC (permalink / raw)
  To: Florian Fainelli, netdev
  Cc: Randy Dunlap, Jonathan Cameron, David S. Miller,
	santosh.shilimkar, Sekhar Nori, linux-doc, linux-kernel,
	davinci-linux-open-source, sergei.shtylyov, prabhakar.csengg,
	Grygorii Strashko

Add a resource managed devm_mdiobus_alloc[_size]()/devm_mdiobus_free()
to automatically clean up MDIO bus alocations made by MDIO drivers,
thus leading to simplified MDIO drivers code.

Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Acked-and-tested-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
 Documentation/driver-model/devres.txt |    5 +++
 drivers/net/phy/mdio_bus.c            |   67 +++++++++++++++++++++++++++++++++
 include/linux/phy.h                   |    7 ++++
 3 files changed, 79 insertions(+)

diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
index 4f7897e..c74e044 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -308,3 +308,8 @@ SLAVE DMA ENGINE
 
 SPI
   devm_spi_register_master()
+
+MDIO
+  devm_mdiobus_alloc()
+  devm_mdiobus_alloc_size()
+  devm_mdiobus_free()
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 76f54b3..68a9a38 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -69,6 +69,73 @@ struct mii_bus *mdiobus_alloc_size(size_t size)
 }
 EXPORT_SYMBOL(mdiobus_alloc_size);
 
+static void _devm_mdiobus_free(struct device *dev, void *res)
+{
+	mdiobus_free(*(struct mii_bus **)res);
+}
+
+static int devm_mdiobus_match(struct device *dev, void *res, void *data)
+{
+	struct mii_bus **r = res;
+
+	if (WARN_ON(!r || !*r))
+		return 0;
+
+	return *r == data;
+}
+
+/**
+ * devm_mdiobus_alloc_size - Resource-managed mdiobus_alloc_size()
+ * @dev:		Device to allocate mii_bus for
+ * @sizeof_priv:	Space to allocate for private structure.
+ *
+ * Managed mdiobus_alloc_size. mii_bus allocated with this function is
+ * automatically freed on driver detach.
+ *
+ * If an mii_bus allocated with this function needs to be freed separately,
+ * devm_mdiobus_free() must be used.
+ *
+ * RETURNS:
+ * Pointer to allocated mii_bus on success, NULL on failure.
+ */
+struct mii_bus *devm_mdiobus_alloc_size(struct device *dev, int sizeof_priv)
+{
+	struct mii_bus **ptr, *bus;
+
+	ptr = devres_alloc(_devm_mdiobus_free, sizeof(*ptr), GFP_KERNEL);
+	if (!ptr)
+		return NULL;
+
+	/* use raw alloc_dr for kmalloc caller tracing */
+	bus = mdiobus_alloc_size(sizeof_priv);
+	if (bus) {
+		*ptr = bus;
+		devres_add(dev, ptr);
+	} else {
+		devres_free(ptr);
+	}
+
+	return bus;
+}
+EXPORT_SYMBOL_GPL(devm_mdiobus_alloc);
+
+/**
+ * devm_mdiobus_free - Resource-managed mdiobus_free()
+ * @dev:		Device this mii_bus belongs to
+ * @bus:		the mii_bus associated with the device
+ *
+ * Free mii_bus allocated with devm_mdiobus_alloc_size().
+ */
+void devm_mdiobus_free(struct device *dev, struct mii_bus *bus)
+{
+	int rc;
+
+	rc = devres_release(dev, _devm_mdiobus_free,
+			    devm_mdiobus_match, bus);
+	WARN_ON(rc);
+}
+EXPORT_SYMBOL_GPL(devm_mdiobus_free);
+
 /**
  * mdiobus_release - mii_bus device release callback
  * @d: the target struct device that contains the mii_bus
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 24126c4..d7f5ef8 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -195,6 +195,13 @@ static inline struct mii_bus *mdiobus_alloc(void)
 int mdiobus_register(struct mii_bus *bus);
 void mdiobus_unregister(struct mii_bus *bus);
 void mdiobus_free(struct mii_bus *bus);
+struct mii_bus *devm_mdiobus_alloc_size(struct device *dev, int sizeof_priv);
+static inline struct mii_bus *devm_mdiobus_alloc(struct device *dev)
+{
+	return devm_mdiobus_alloc_size(dev, 0);
+}
+
+void devm_mdiobus_free(struct device *dev, struct mii_bus *bus);
 struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr);
 int mdiobus_read(struct mii_bus *bus, int addr, u32 regnum);
 int mdiobus_write(struct mii_bus *bus, int addr, u32 regnum, u16 val);
-- 
1.7.9.5


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

* [PATCH v3 1/4] mdio_bus: implement devm_mdiobus_alloc/devm_mdiobus_free
@ 2014-04-30 12:23   ` Grygorii Strashko
  0 siblings, 0 replies; 13+ messages in thread
From: Grygorii Strashko @ 2014-04-30 12:23 UTC (permalink / raw)
  To: Florian Fainelli, netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/,
	linux-doc-u79uwXL29TY76Z2rM5mHXA, Randy Dunlap,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	santosh.shilimkar-l0cyMroinI0, David S. Miller, Jonathan Cameron

Add a resource managed devm_mdiobus_alloc[_size]()/devm_mdiobus_free()
to automatically clean up MDIO bus alocations made by MDIO drivers,
thus leading to simplified MDIO drivers code.

Cc: Florian Fainelli <f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Sergei Shtylyov <sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
Acked-and-tested-by: Lad, Prabhakar <prabhakar.csengg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Signed-off-by: Grygorii Strashko <grygorii.strashko-l0cyMroinI0@public.gmane.org>
---
 Documentation/driver-model/devres.txt |    5 +++
 drivers/net/phy/mdio_bus.c            |   67 +++++++++++++++++++++++++++++++++
 include/linux/phy.h                   |    7 ++++
 3 files changed, 79 insertions(+)

diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
index 4f7897e..c74e044 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -308,3 +308,8 @@ SLAVE DMA ENGINE
 
 SPI
   devm_spi_register_master()
+
+MDIO
+  devm_mdiobus_alloc()
+  devm_mdiobus_alloc_size()
+  devm_mdiobus_free()
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 76f54b3..68a9a38 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -69,6 +69,73 @@ struct mii_bus *mdiobus_alloc_size(size_t size)
 }
 EXPORT_SYMBOL(mdiobus_alloc_size);
 
+static void _devm_mdiobus_free(struct device *dev, void *res)
+{
+	mdiobus_free(*(struct mii_bus **)res);
+}
+
+static int devm_mdiobus_match(struct device *dev, void *res, void *data)
+{
+	struct mii_bus **r = res;
+
+	if (WARN_ON(!r || !*r))
+		return 0;
+
+	return *r == data;
+}
+
+/**
+ * devm_mdiobus_alloc_size - Resource-managed mdiobus_alloc_size()
+ * @dev:		Device to allocate mii_bus for
+ * @sizeof_priv:	Space to allocate for private structure.
+ *
+ * Managed mdiobus_alloc_size. mii_bus allocated with this function is
+ * automatically freed on driver detach.
+ *
+ * If an mii_bus allocated with this function needs to be freed separately,
+ * devm_mdiobus_free() must be used.
+ *
+ * RETURNS:
+ * Pointer to allocated mii_bus on success, NULL on failure.
+ */
+struct mii_bus *devm_mdiobus_alloc_size(struct device *dev, int sizeof_priv)
+{
+	struct mii_bus **ptr, *bus;
+
+	ptr = devres_alloc(_devm_mdiobus_free, sizeof(*ptr), GFP_KERNEL);
+	if (!ptr)
+		return NULL;
+
+	/* use raw alloc_dr for kmalloc caller tracing */
+	bus = mdiobus_alloc_size(sizeof_priv);
+	if (bus) {
+		*ptr = bus;
+		devres_add(dev, ptr);
+	} else {
+		devres_free(ptr);
+	}
+
+	return bus;
+}
+EXPORT_SYMBOL_GPL(devm_mdiobus_alloc);
+
+/**
+ * devm_mdiobus_free - Resource-managed mdiobus_free()
+ * @dev:		Device this mii_bus belongs to
+ * @bus:		the mii_bus associated with the device
+ *
+ * Free mii_bus allocated with devm_mdiobus_alloc_size().
+ */
+void devm_mdiobus_free(struct device *dev, struct mii_bus *bus)
+{
+	int rc;
+
+	rc = devres_release(dev, _devm_mdiobus_free,
+			    devm_mdiobus_match, bus);
+	WARN_ON(rc);
+}
+EXPORT_SYMBOL_GPL(devm_mdiobus_free);
+
 /**
  * mdiobus_release - mii_bus device release callback
  * @d: the target struct device that contains the mii_bus
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 24126c4..d7f5ef8 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -195,6 +195,13 @@ static inline struct mii_bus *mdiobus_alloc(void)
 int mdiobus_register(struct mii_bus *bus);
 void mdiobus_unregister(struct mii_bus *bus);
 void mdiobus_free(struct mii_bus *bus);
+struct mii_bus *devm_mdiobus_alloc_size(struct device *dev, int sizeof_priv);
+static inline struct mii_bus *devm_mdiobus_alloc(struct device *dev)
+{
+	return devm_mdiobus_alloc_size(dev, 0);
+}
+
+void devm_mdiobus_free(struct device *dev, struct mii_bus *bus);
 struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr);
 int mdiobus_read(struct mii_bus *bus, int addr, u32 regnum);
 int mdiobus_write(struct mii_bus *bus, int addr, u32 regnum, u16 val);
-- 
1.7.9.5

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

* [PATCH v3 2/4] net: davinci_mdio: use devm_* api
@ 2014-04-30 12:23   ` Grygorii Strashko
  0 siblings, 0 replies; 13+ messages in thread
From: Grygorii Strashko @ 2014-04-30 12:23 UTC (permalink / raw)
  To: Florian Fainelli, netdev
  Cc: Randy Dunlap, Jonathan Cameron, David S. Miller,
	santosh.shilimkar, Sekhar Nori, linux-doc, linux-kernel,
	davinci-linux-open-source, sergei.shtylyov, prabhakar.csengg,
	Grygorii Strashko

Use devm_* API for memory allocation and to get device's clock
to simplify driver's code.

Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Acked-and-tested-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
 drivers/net/ethernet/ti/davinci_mdio.c |   24 +++++-------------------
 1 file changed, 5 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
index 0cca9de..4b202a2 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -321,15 +321,14 @@ static int davinci_mdio_probe(struct platform_device *pdev)
 	struct phy_device *phy;
 	int ret, addr;
 
-	data = kzalloc(sizeof(*data), GFP_KERNEL);
+	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
 
-	data->bus = mdiobus_alloc();
+	data->bus = devm_mdiobus_alloc(dev);
 	if (!data->bus) {
 		dev_err(dev, "failed to alloc mii bus\n");
-		ret = -ENOMEM;
-		goto bail_out;
+		return -ENOMEM;
 	}
 
 	if (dev->of_node) {
@@ -354,7 +353,7 @@ static int davinci_mdio_probe(struct platform_device *pdev)
 
 	pm_runtime_enable(&pdev->dev);
 	pm_runtime_get_sync(&pdev->dev);
-	data->clk = clk_get(&pdev->dev, "fck");
+	data->clk = devm_clk_get(dev, "fck");
 	if (IS_ERR(data->clk)) {
 		dev_err(dev, "failed to get device clock\n");
 		ret = PTR_ERR(data->clk);
@@ -406,16 +405,9 @@ static int davinci_mdio_probe(struct platform_device *pdev)
 	return 0;
 
 bail_out:
-	if (data->bus)
-		mdiobus_free(data->bus);
-
-	if (data->clk)
-		clk_put(data->clk);
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
-	kfree(data);
-
 	return ret;
 }
 
@@ -423,18 +415,12 @@ static int davinci_mdio_remove(struct platform_device *pdev)
 {
 	struct davinci_mdio_data *data = platform_get_drvdata(pdev);
 
-	if (data->bus) {
+	if (data->bus)
 		mdiobus_unregister(data->bus);
-		mdiobus_free(data->bus);
-	}
 
-	if (data->clk)
-		clk_put(data->clk);
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
-	kfree(data);
-
 	return 0;
 }
 
-- 
1.7.9.5


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

* [PATCH v3 2/4] net: davinci_mdio: use devm_* api
@ 2014-04-30 12:23   ` Grygorii Strashko
  0 siblings, 0 replies; 13+ messages in thread
From: Grygorii Strashko @ 2014-04-30 12:23 UTC (permalink / raw)
  To: Florian Fainelli, netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/,
	linux-doc-u79uwXL29TY76Z2rM5mHXA, Randy Dunlap,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	santosh.shilimkar-l0cyMroinI0, David S. Miller, Jonathan Cameron

Use devm_* API for memory allocation and to get device's clock
to simplify driver's code.

Cc: Florian Fainelli <f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Sergei Shtylyov <sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
Acked-and-tested-by: Lad, Prabhakar <prabhakar.csengg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Signed-off-by: Grygorii Strashko <grygorii.strashko-l0cyMroinI0@public.gmane.org>
---
 drivers/net/ethernet/ti/davinci_mdio.c |   24 +++++-------------------
 1 file changed, 5 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
index 0cca9de..4b202a2 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -321,15 +321,14 @@ static int davinci_mdio_probe(struct platform_device *pdev)
 	struct phy_device *phy;
 	int ret, addr;
 
-	data = kzalloc(sizeof(*data), GFP_KERNEL);
+	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
 
-	data->bus = mdiobus_alloc();
+	data->bus = devm_mdiobus_alloc(dev);
 	if (!data->bus) {
 		dev_err(dev, "failed to alloc mii bus\n");
-		ret = -ENOMEM;
-		goto bail_out;
+		return -ENOMEM;
 	}
 
 	if (dev->of_node) {
@@ -354,7 +353,7 @@ static int davinci_mdio_probe(struct platform_device *pdev)
 
 	pm_runtime_enable(&pdev->dev);
 	pm_runtime_get_sync(&pdev->dev);
-	data->clk = clk_get(&pdev->dev, "fck");
+	data->clk = devm_clk_get(dev, "fck");
 	if (IS_ERR(data->clk)) {
 		dev_err(dev, "failed to get device clock\n");
 		ret = PTR_ERR(data->clk);
@@ -406,16 +405,9 @@ static int davinci_mdio_probe(struct platform_device *pdev)
 	return 0;
 
 bail_out:
-	if (data->bus)
-		mdiobus_free(data->bus);
-
-	if (data->clk)
-		clk_put(data->clk);
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
-	kfree(data);
-
 	return ret;
 }
 
@@ -423,18 +415,12 @@ static int davinci_mdio_remove(struct platform_device *pdev)
 {
 	struct davinci_mdio_data *data = platform_get_drvdata(pdev);
 
-	if (data->bus) {
+	if (data->bus)
 		mdiobus_unregister(data->bus);
-		mdiobus_free(data->bus);
-	}
 
-	if (data->clk)
-		clk_put(data->clk);
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
-	kfree(data);
-
 	return 0;
 }
 
-- 
1.7.9.5

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

* [PATCH v3 3/4] net: davinci_mdio: drop pinctrl_pm_select_default_state from probe
  2014-04-30 12:23 ` Grygorii Strashko
                   ` (2 preceding siblings ...)
  (?)
@ 2014-04-30 12:23 ` Grygorii Strashko
  2014-05-09 11:41     ` Linus Walleij
  -1 siblings, 1 reply; 13+ messages in thread
From: Grygorii Strashko @ 2014-04-30 12:23 UTC (permalink / raw)
  To: Florian Fainelli, netdev
  Cc: Randy Dunlap, Jonathan Cameron, David S. Miller,
	santosh.shilimkar, Sekhar Nori, linux-doc, linux-kernel,
	davinci-linux-open-source, sergei.shtylyov, prabhakar.csengg,
	Grygorii Strashko, Linus Walleij

The "default" pinctrl state is set by Drivers core now before
calling the driver's probe.
Hence, it's safe to drop pinctrl_pm_select_default_state() call
from Davinci mdio driver probe.

Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Acked-and-tested-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
 drivers/net/ethernet/ti/davinci_mdio.c |    3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
index 4b202a2..4757198 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -348,9 +348,6 @@ static int davinci_mdio_probe(struct platform_device *pdev)
 	data->bus->parent	= dev;
 	data->bus->priv		= data;
 
-	/* Select default pin state */
-	pinctrl_pm_select_default_state(&pdev->dev);
-
 	pm_runtime_enable(&pdev->dev);
 	pm_runtime_get_sync(&pdev->dev);
 	data->clk = devm_clk_get(dev, "fck");
-- 
1.7.9.5


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

* [PATCH v3 4/4] net: davinci_mdio: simplify IO memory mapping
  2014-04-30 12:23 ` Grygorii Strashko
                   ` (3 preceding siblings ...)
  (?)
@ 2014-04-30 12:23 ` Grygorii Strashko
  -1 siblings, 0 replies; 13+ messages in thread
From: Grygorii Strashko @ 2014-04-30 12:23 UTC (permalink / raw)
  To: Florian Fainelli, netdev
  Cc: Randy Dunlap, Jonathan Cameron, David S. Miller,
	santosh.shilimkar, Sekhar Nori, linux-doc, linux-kernel,
	davinci-linux-open-source, sergei.shtylyov, prabhakar.csengg,
	Grygorii Strashko

Simplify IO memory mapping by using devm_ioremap_resource()
which will do all errors handling and reporting for us.

Acked-and-tested-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
 drivers/net/ethernet/ti/davinci_mdio.c |   21 +++------------------
 1 file changed, 3 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
index 4757198..34e97ec 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -363,24 +363,9 @@ static int davinci_mdio_probe(struct platform_device *pdev)
 	spin_lock_init(&data->lock);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(dev, "could not find register map resource\n");
-		ret = -ENOENT;
-		goto bail_out;
-	}
-
-	res = devm_request_mem_region(dev, res->start, resource_size(res),
-					    dev_name(dev));
-	if (!res) {
-		dev_err(dev, "could not allocate register map resource\n");
-		ret = -ENXIO;
-		goto bail_out;
-	}
-
-	data->regs = devm_ioremap_nocache(dev, res->start, resource_size(res));
-	if (!data->regs) {
-		dev_err(dev, "could not map mdio registers\n");
-		ret = -ENOMEM;
+	data->regs = devm_ioremap_resource(dev, res);
+	if (IS_ERR(data->regs)) {
+		ret = PTR_ERR(data->regs);
 		goto bail_out;
 	}
 
-- 
1.7.9.5


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

* Re: [PATCH v3 0/4] introduce devm_mdiobus_alloc/free and clean up davinci mdio
@ 2014-04-30 14:25   ` Santosh Shilimkar
  0 siblings, 0 replies; 13+ messages in thread
From: Santosh Shilimkar @ 2014-04-30 14:25 UTC (permalink / raw)
  To: Grygorii Strashko, Florian Fainelli, netdev
  Cc: Randy Dunlap, Jonathan Cameron, David S. Miller, Sekhar Nori,
	linux-doc, linux-kernel, davinci-linux-open-source,
	sergei.shtylyov, prabhakar.csengg

On Wednesday 30 April 2014 08:23 AM, Grygorii Strashko wrote:
> Introduce a resource managed devm_mdiobus_alloc[_size]()/devm_mdiobus_free()
> to automatically clean up MDIO bus alocations made by MDIO drivers,
> thus leading to simplified MDIO drivers code.
> 
> Clean up Davinci MDIO driver and use new devm API.
> 
> Changes in v3:
> - added devm_mdiobus_alloc_size() and
>   devm_mdiobus_alloc() converted to be just a simple wrapper now.
> 
> Changes in v2:
> - minor comments taken into account
> - additional patches added for cleaning up Davinci MDIO driver
> 
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> 
> Grygorii Strashko (4):
>   mdio_bus: implement devm_mdiobus_alloc/devm_mdiobus_free
>   net: davinci_mdio: use devm_* api
>   net: davinci_mdio: drop pinctrl_pm_select_default_state from probe
>   net: davinci_mdio: simplify IO memory mapping
> 
Thanks for the updates. The series looks good to me.
Feel free to my ack if you need one...
Acked-by: Santosh Shilimkar<santosh.shilimkar@ti.com>


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

* Re: [PATCH v3 0/4] introduce devm_mdiobus_alloc/free and clean up davinci mdio
@ 2014-04-30 14:25   ` Santosh Shilimkar
  0 siblings, 0 replies; 13+ messages in thread
From: Santosh Shilimkar @ 2014-04-30 14:25 UTC (permalink / raw)
  To: Grygorii Strashko, Florian Fainelli, netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/,
	linux-doc-u79uwXL29TY76Z2rM5mHXA, Randy Dunlap,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, David S. Miller,
	Jonathan Cameron

On Wednesday 30 April 2014 08:23 AM, Grygorii Strashko wrote:
> Introduce a resource managed devm_mdiobus_alloc[_size]()/devm_mdiobus_free()
> to automatically clean up MDIO bus alocations made by MDIO drivers,
> thus leading to simplified MDIO drivers code.
> 
> Clean up Davinci MDIO driver and use new devm API.
> 
> Changes in v3:
> - added devm_mdiobus_alloc_size() and
>   devm_mdiobus_alloc() converted to be just a simple wrapper now.
> 
> Changes in v2:
> - minor comments taken into account
> - additional patches added for cleaning up Davinci MDIO driver
> 
> Cc: Florian Fainelli <f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> 
> Grygorii Strashko (4):
>   mdio_bus: implement devm_mdiobus_alloc/devm_mdiobus_free
>   net: davinci_mdio: use devm_* api
>   net: davinci_mdio: drop pinctrl_pm_select_default_state from probe
>   net: davinci_mdio: simplify IO memory mapping
> 
Thanks for the updates. The series looks good to me.
Feel free to my ack if you need one...
Acked-by: Santosh Shilimkar<santosh.shilimkar-l0cyMroinI0@public.gmane.org>

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

* Re: [PATCH v3 0/4] introduce devm_mdiobus_alloc/free and clean up davinci mdio
  2014-04-30 12:23 ` Grygorii Strashko
                   ` (5 preceding siblings ...)
  (?)
@ 2014-05-02 20:17 ` David Miller
  -1 siblings, 0 replies; 13+ messages in thread
From: David Miller @ 2014-05-02 20:17 UTC (permalink / raw)
  To: grygorii.strashko
  Cc: f.fainelli, netdev, rdunlap, jic23, santosh.shilimkar, nsekhar,
	linux-doc, linux-kernel, davinci-linux-open-source,
	sergei.shtylyov, prabhakar.csengg

From: Grygorii Strashko <grygorii.strashko@ti.com>
Date: Wed, 30 Apr 2014 15:23:32 +0300

> Introduce a resource managed devm_mdiobus_alloc[_size]()/devm_mdiobus_free()
> to automatically clean up MDIO bus alocations made by MDIO drivers,
> thus leading to simplified MDIO drivers code.
> 
> Clean up Davinci MDIO driver and use new devm API.
> 
> Changes in v3:
> - added devm_mdiobus_alloc_size() and
>   devm_mdiobus_alloc() converted to be just a simple wrapper now.
> 
> Changes in v2:
> - minor comments taken into account
> - additional patches added for cleaning up Davinci MDIO driver

Series applied to net-next, thanks.

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

* Re: [PATCH v3 3/4] net: davinci_mdio: drop pinctrl_pm_select_default_state from probe
  2014-04-30 12:23 ` [PATCH v3 3/4] net: davinci_mdio: drop pinctrl_pm_select_default_state from probe Grygorii Strashko
@ 2014-05-09 11:41     ` Linus Walleij
  0 siblings, 0 replies; 13+ messages in thread
From: Linus Walleij @ 2014-05-09 11:41 UTC (permalink / raw)
  To: Grygorii Strashko
  Cc: Florian Fainelli, netdev, Randy Dunlap, Jonathan Cameron,
	David S. Miller, Santosh Shilimkar, Sekhar Nori, linux-doc,
	linux-kernel, davinci-linux-open-source, Sergei Shtylyov,
	Prabhakar Lad

On Wed, Apr 30, 2014 at 2:23 PM, Grygorii Strashko
<grygorii.strashko@ti.com> wrote:

> The "default" pinctrl state is set by Drivers core now before
> calling the driver's probe.
> Hence, it's safe to drop pinctrl_pm_select_default_state() call
> from Davinci mdio driver probe.
>
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Acked-and-tested-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH v3 3/4] net: davinci_mdio: drop pinctrl_pm_select_default_state from probe
@ 2014-05-09 11:41     ` Linus Walleij
  0 siblings, 0 replies; 13+ messages in thread
From: Linus Walleij @ 2014-05-09 11:41 UTC (permalink / raw)
  To: Grygorii Strashko
  Cc: Florian Fainelli, netdev, Randy Dunlap, Jonathan Cameron,
	David S. Miller, Santosh Shilimkar, Sekhar Nori, linux-doc,
	linux-kernel, davinci-linux-open-source, Sergei Shtylyov,
	Prabhakar Lad

On Wed, Apr 30, 2014 at 2:23 PM, Grygorii Strashko
<grygorii.strashko@ti.com> wrote:

> The "default" pinctrl state is set by Drivers core now before
> calling the driver's probe.
> Hence, it's safe to drop pinctrl_pm_select_default_state() call
> from Davinci mdio driver probe.
>
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Acked-and-tested-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

end of thread, other threads:[~2014-05-09 11:41 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-30 12:23 [PATCH v3 0/4] introduce devm_mdiobus_alloc/free and clean up davinci mdio Grygorii Strashko
2014-04-30 12:23 ` Grygorii Strashko
2014-04-30 12:23 ` [PATCH v3 1/4] mdio_bus: implement devm_mdiobus_alloc/devm_mdiobus_free Grygorii Strashko
2014-04-30 12:23   ` Grygorii Strashko
2014-04-30 12:23 ` [PATCH v3 2/4] net: davinci_mdio: use devm_* api Grygorii Strashko
2014-04-30 12:23   ` Grygorii Strashko
2014-04-30 12:23 ` [PATCH v3 3/4] net: davinci_mdio: drop pinctrl_pm_select_default_state from probe Grygorii Strashko
2014-05-09 11:41   ` Linus Walleij
2014-05-09 11:41     ` Linus Walleij
2014-04-30 12:23 ` [PATCH v3 4/4] net: davinci_mdio: simplify IO memory mapping Grygorii Strashko
2014-04-30 14:25 ` [PATCH v3 0/4] introduce devm_mdiobus_alloc/free and clean up davinci mdio Santosh Shilimkar
2014-04-30 14:25   ` Santosh Shilimkar
2014-05-02 20:17 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.