Skip to contentSkip to conversation

net: mdio-gpio enhancements

PATCH In review Guenter Roeck 4 participants 13 messages Apr 16, 2014 – Apr 18, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover net: mdio-gpio enhancements

The following series of patches adds support for active-low gpio pins as well as for systems with separate MDI and MDO pins to the mdio-gpio driver.

A board using those features is based on a COM Express CPU board. The COM Express standard supports GPIO pins on its connector, with one caveat: The pins on the connector have fixed direction and are hard configured either as input or output pins. The COM Express Design Guide [1] provides additional details.

The hardware uses three of the GPO/GPI pins from the COM Express board to drive an MDIO bus. Connectivity between GPI/GPO pins and the MDIO bus is as follows.

GPI2 --------------------+------------ MDIO

                         |
            +--------+   |
GPO2 ---+---G        |   |
        |   |        |   |
       4.7k | 2N7002 D---+
	|   |        |
	+---S        |
	|   +--------+
       GND

GPO1 --------------------------------- MDC

To support this hardware, two extensions to the driver were necessary.

- Due to the FET in the MDO path (GPO2), the MDO signal is inverted. The driver therefore has to support active-low GPIO pins.

- The MDIO signal must be separated into MDI and MDO.

Those changes are implemented in patch 2/3 and 3/3. Patch 1/3 simplifies the error path and thus the subsequent patches.

[1] http://www.picmg.org/pdf/picmg_comdg_100.pdf

----------------------------------------------------------------
Guenter Roeck (3):
net: mdio-gpio: Use devm_ functions where possible
net: mdio-gpio: Add support for active low gpio pins
net: mdio-gpio: Add support for separate MDI and MDO gpio pins

 drivers/net/phy/mdio-gpio.c |   68 ++++++++++++++++++++++++++++++-------------
 include/linux/mdio-gpio.h   |    5 ++++
 2 files changed, 52 insertions(+), 21 deletions(-)
#1 lore raw

PATCH 1/3 net: mdio-gpio: Use devm_ functions where possible

This simplifies error path and deinit/removal functions.

---
 drivers/net/phy/mdio-gpio.c |   19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)
drivers/net/phy/mdio-gpio.c +5 -14
index e701433..e853066 100644
@@ -110,7 +110,7 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev,
 	struct mdio_gpio_info *bitbang;
 	int i;
 
-	bitbang = kzalloc(sizeof(*bitbang), GFP_KERNEL);
+	bitbang = devm_kzalloc(dev, sizeof(*bitbang), GFP_KERNEL);
 	if (!bitbang)
 		goto out;
 
@@ -121,7 +121,7 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev,
 
 	new_bus = alloc_mdio_bitbang(&bitbang->ctrl);
 	if (!new_bus)
-		goto out_free_bitbang;
+		goto out;
 
 	new_bus->name = "GPIO Bitbanged MDIO",
 
@@ -138,11 +138,11 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev,
 
 	snprintf(new_bus->id, MII_BUS_ID_SIZE, "gpio-%x", bus_id);
 
-	if (gpio_request(bitbang->mdc, "mdc"))
+	if (devm_gpio_request(dev, bitbang->mdc, "mdc"))
 		goto out_free_bus;
 
-	if (gpio_request(bitbang->mdio, "mdio"))
-		goto out_free_mdc;
+	if (devm_gpio_request(dev, bitbang->mdio, "mdio"))
+		goto out_free_bus;
 
 	gpio_direction_output(bitbang->mdc, 0);
 
@@ -150,12 +150,8 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev,
 
 	return new_bus;
 
-out_free_mdc:
-	gpio_free(bitbang->mdc);
 out_free_bus:
 	free_mdio_bitbang(new_bus);
-out_free_bitbang:
-	kfree(bitbang);
 out:
 	return NULL;
 }
@@ -163,13 +159,8 @@ out:
 static void mdio_gpio_bus_deinit(struct device *dev)
 {
 	struct mii_bus *bus = dev_get_drvdata(dev);
-	struct mdio_gpio_info *bitbang = bus->priv;
 
-	dev_set_drvdata(dev, NULL);
-	gpio_free(bitbang->mdio);
-	gpio_free(bitbang->mdc);
 	free_mdio_bitbang(bus);
-	kfree(bitbang);
 }
 
 static void mdio_gpio_bus_destroy(struct device *dev)
Signature · 1 line
1.7.9.7
#8 lore raw

PATCH 2/3 net: mdio-gpio: Add support for active low gpio pins

In reply to Guenter Roeck

Some systems using mdio-gpio may use active-low gpio pins (eg with inverters or FETs connected to all or some of the gpio pins).

---
 drivers/net/phy/mdio-gpio.c |   19 +++++++++++++------
 include/linux/mdio-gpio.h   |    3 +++
 2 files changed, 16 insertions(+), 6 deletions(-)
drivers/net/phy/mdio-gpio.c +13 -6
index e853066..fac211a 100644
@@ -33,28 +33,32 @@
 struct mdio_gpio_info {
 	struct mdiobb_ctrl ctrl;
 	int mdc, mdio;
+	int mdc_active_low, mdio_active_low;
 };
 
 static void *mdio_gpio_of_get_data(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
 	struct mdio_gpio_platform_data *pdata;
+	enum of_gpio_flags flags;
 	int ret;
 
 	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
 	if (!pdata)
 		return NULL;
 
-	ret = of_get_gpio(np, 0);
+	ret = of_get_gpio_flags(np, 0, &flags);
 	if (ret < 0)
 		return NULL;
 
 	pdata->mdc = ret;
+	pdata->mdc_active_low = flags & OF_GPIO_ACTIVE_LOW;
 
-	ret = of_get_gpio(np, 1);
+	ret = of_get_gpio_flags(np, 1, &flags);
 	if (ret < 0)
 		return NULL;
 	pdata->mdio = ret;
+	pdata->mdio_active_low = flags & OF_GPIO_ACTIVE_LOW;
 
 	return pdata;
 }
@@ -65,7 +69,8 @@ static void mdio_dir(struct mdiobb_ctrl *ctrl, int dir)
 		container_of(ctrl, struct mdio_gpio_info, ctrl);
 
 	if (dir)
-		gpio_direction_output(bitbang->mdio, 1);
+		gpio_direction_output(bitbang->mdio,
+				      1 ^ bitbang->mdio_active_low);
 	else
 		gpio_direction_input(bitbang->mdio);
 }
@@ -75,7 +80,7 @@ static int mdio_get(struct mdiobb_ctrl *ctrl)
 	struct mdio_gpio_info *bitbang =
 		container_of(ctrl, struct mdio_gpio_info, ctrl);
 
-	return gpio_get_value(bitbang->mdio);
+	return gpio_get_value(bitbang->mdio) ^ bitbang->mdio_active_low;
 }
 
 static void mdio_set(struct mdiobb_ctrl *ctrl, int what)
@@ -83,7 +88,7 @@ static void mdio_set(struct mdiobb_ctrl *ctrl, int what)
 	struct mdio_gpio_info *bitbang =
 		container_of(ctrl, struct mdio_gpio_info, ctrl);
 
-	gpio_set_value(bitbang->mdio, what);
+	gpio_set_value(bitbang->mdio, what ^ bitbang->mdio_active_low);
 }
 
 static void mdc_set(struct mdiobb_ctrl *ctrl, int what)
@@ -91,7 +96,7 @@ static void mdc_set(struct mdiobb_ctrl *ctrl, int what)
 	struct mdio_gpio_info *bitbang =
 		container_of(ctrl, struct mdio_gpio_info, ctrl);
 
-	gpio_set_value(bitbang->mdc, what);
+	gpio_set_value(bitbang->mdc, what ^ bitbang->mdc_active_low);
 }
 
 static struct mdiobb_ops mdio_gpio_ops = {
@@ -117,7 +122,9 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev,
 	bitbang->ctrl.ops = &mdio_gpio_ops;
 	bitbang->ctrl.reset = pdata->reset;
 	bitbang->mdc = pdata->mdc;
+	bitbang->mdc_active_low = pdata->mdc_active_low;
 	bitbang->mdio = pdata->mdio;
+	bitbang->mdio_active_low = pdata->mdio_active_low;
 
 	new_bus = alloc_mdio_bitbang(&bitbang->ctrl);
 	if (!new_bus)
include/linux/mdio-gpio.h +3 -0
index 7c9fe3c..57e57fe 100644
@@ -18,6 +18,9 @@ struct mdio_gpio_platform_data {
 	unsigned int mdc;
 	unsigned int mdio;
 
+	bool mdc_active_low;
+	bool mdio_active_low;
+
 	unsigned int phy_mask;
 	int irqs[PHY_MAX_ADDR];
 	/* reset callback */
Signature · 1 line
1.7.9.7
#10 lore raw

PATCH 3/3 net: mdio-gpio: Add support for separate MDI and MDO gpio pins

In reply to Guenter Roeck

This is for a system with fixed assignments of input and output pins (various variants of Kontron COMe).

---
 drivers/net/phy/mdio-gpio.c |   34 +++++++++++++++++++++++++++++++---
 include/linux/mdio-gpio.h   |    2 ++
 2 files changed, 33 insertions(+), 3 deletions(-)
drivers/net/phy/mdio-gpio.c +31 -3
index fac211a..9c4defd 100644
@@ -32,8 +32,8 @@
 
 struct mdio_gpio_info {
 	struct mdiobb_ctrl ctrl;
-	int mdc, mdio;
-	int mdc_active_low, mdio_active_low;
+	int mdc, mdio, mdo;
+	int mdc_active_low, mdio_active_low, mdo_active_low;
 };
 
 static void *mdio_gpio_of_get_data(struct platform_device *pdev)
@@ -60,6 +60,12 @@ static void *mdio_gpio_of_get_data(struct platform_device *pdev)
 	pdata->mdio = ret;
 	pdata->mdio_active_low = flags & OF_GPIO_ACTIVE_LOW;
 
+	ret = of_get_gpio_flags(np, 2, &flags);
+	if (ret > 0) {
+		pdata->mdo = ret;
+		pdata->mdo_active_low = flags & OF_GPIO_ACTIVE_LOW;
+	}
+
 	return pdata;
 }
 
@@ -68,6 +74,16 @@ static void mdio_dir(struct mdiobb_ctrl *ctrl, int dir)
 	struct mdio_gpio_info *bitbang =
 		container_of(ctrl, struct mdio_gpio_info, ctrl);
 
+	if (bitbang->mdo) {
+		/* Separate output pin. Always set its value to high
+		 * when changing direction. If direction is input,
+		 * assume the pin serves as pull-up. If direction is
+		 * output, the default value is high.
+		 */
+		gpio_set_value(bitbang->mdo, 1 ^ bitbang->mdo_active_low);
+		return;
+	}
+
 	if (dir)
 		gpio_direction_output(bitbang->mdio,
 				      1 ^ bitbang->mdio_active_low);
@@ -88,7 +104,10 @@ static void mdio_set(struct mdiobb_ctrl *ctrl, int what)
 	struct mdio_gpio_info *bitbang =
 		container_of(ctrl, struct mdio_gpio_info, ctrl);
 
-	gpio_set_value(bitbang->mdio, what ^ bitbang->mdio_active_low);
+	if (bitbang->mdo)
+		gpio_set_value(bitbang->mdo, what ^ bitbang->mdo_active_low);
+	else
+		gpio_set_value(bitbang->mdio, what ^ bitbang->mdio_active_low);
 }
 
 static void mdc_set(struct mdiobb_ctrl *ctrl, int what)
@@ -125,6 +144,8 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev,
 	bitbang->mdc_active_low = pdata->mdc_active_low;
 	bitbang->mdio = pdata->mdio;
 	bitbang->mdio_active_low = pdata->mdio_active_low;
+	bitbang->mdo = pdata->mdo;
+	bitbang->mdo_active_low = pdata->mdo_active_low;
 
 	new_bus = alloc_mdio_bitbang(&bitbang->ctrl);
 	if (!new_bus)
@@ -151,6 +172,13 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev,
 	if (devm_gpio_request(dev, bitbang->mdio, "mdio"))
 		goto out_free_bus;
 
+	if (bitbang->mdo) {
+		if (devm_gpio_request(dev, bitbang->mdo, "mdo"))
+			goto out_free_bus;
+		gpio_direction_output(bitbang->mdo, 1);
+		gpio_direction_input(bitbang->mdio);
+	}
+
 	gpio_direction_output(bitbang->mdc, 0);
 
 	dev_set_drvdata(dev, new_bus);
include/linux/mdio-gpio.h +2 -0
index 57e57fe..66c30a7 100644
@@ -17,9 +17,11 @@ struct mdio_gpio_platform_data {
 	/* GPIO numbers for bus pins */
 	unsigned int mdc;
 	unsigned int mdio;
+	unsigned int mdo;
 
 	bool mdc_active_low;
 	bool mdio_active_low;
+	bool mdo_active_low;
 
 	unsigned int phy_mask;
 	int irqs[PHY_MAX_ADDR];
Signature · 1 line
1.7.9.7
Tested-by on v1 2/3
#9 lore raw

RE: [PATCH 2/3] net: mdio-gpio: Add support for active low gpio pins

In reply to Guenter Roeck

Some systems using mdio-gpio may use active-low gpio pins (eg with inverters or FETs connected to all or some of the gpio pins).

---
 drivers/net/phy/mdio-gpio.c |   19 +++++++++++++------
 include/linux/mdio-gpio.h   |    3 +++
 2 files changed, 16 insertions(+), 6 deletions(-)
drivers/net/phy/mdio-gpio.c +13 -6
index e853066..fac211a 100644
@@ -33,28 +33,32 @@
 struct mdio_gpio_info {
        struct mdiobb_ctrl ctrl;
        int mdc, mdio;
+       int mdc_active_low, mdio_active_low;
 };
 
 static void *mdio_gpio_of_get_data(struct platform_device *pdev)
 {
        struct device_node *np = pdev->dev.of_node;
        struct mdio_gpio_platform_data *pdata;
+       enum of_gpio_flags flags;
        int ret;
 
        pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
        if (!pdata)
                return NULL;
 
-       ret = of_get_gpio(np, 0);
+       ret = of_get_gpio_flags(np, 0, &flags);
        if (ret < 0)
                return NULL;
 
        pdata->mdc = ret;
+       pdata->mdc_active_low = flags & OF_GPIO_ACTIVE_LOW;
 
-       ret = of_get_gpio(np, 1);
+       ret = of_get_gpio_flags(np, 1, &flags);
        if (ret < 0)
                return NULL;
        pdata->mdio = ret;
+       pdata->mdio_active_low = flags & OF_GPIO_ACTIVE_LOW;
 
        return pdata;
 }
@@ -65,7 +69,8 @@ static void mdio_dir(struct mdiobb_ctrl *ctrl, int dir)
                container_of(ctrl, struct mdio_gpio_info, ctrl);
 
        if (dir)
-               gpio_direction_output(bitbang->mdio, 1);
+               gpio_direction_output(bitbang->mdio,
+                                     1 ^ bitbang->mdio_active_low);
        else
                gpio_direction_input(bitbang->mdio);
 }
@@ -75,7 +80,7 @@ static int mdio_get(struct mdiobb_ctrl *ctrl)
        struct mdio_gpio_info *bitbang =
                container_of(ctrl, struct mdio_gpio_info, ctrl);
 
-       return gpio_get_value(bitbang->mdio);
+       return gpio_get_value(bitbang->mdio) ^ bitbang->mdio_active_low;
 }
 
 static void mdio_set(struct mdiobb_ctrl *ctrl, int what)
@@ -83,7 +88,7 @@ static void mdio_set(struct mdiobb_ctrl *ctrl, int what)
        struct mdio_gpio_info *bitbang =
                container_of(ctrl, struct mdio_gpio_info, ctrl);
 
-       gpio_set_value(bitbang->mdio, what);
+       gpio_set_value(bitbang->mdio, what ^ bitbang->mdio_active_low);
 }
 
 static void mdc_set(struct mdiobb_ctrl *ctrl, int what)
@@ -91,7 +96,7 @@ static void mdc_set(struct mdiobb_ctrl *ctrl, int what)
        struct mdio_gpio_info *bitbang =
                container_of(ctrl, struct mdio_gpio_info, ctrl);
 
-       gpio_set_value(bitbang->mdc, what);
+       gpio_set_value(bitbang->mdc, what ^ bitbang->mdc_active_low);
 }
 
 static struct mdiobb_ops mdio_gpio_ops = {
@@ -117,7 +122,9 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev,
        bitbang->ctrl.ops = &mdio_gpio_ops;
        bitbang->ctrl.reset = pdata->reset;
        bitbang->mdc = pdata->mdc;
+       bitbang->mdc_active_low = pdata->mdc_active_low;
        bitbang->mdio = pdata->mdio;
+       bitbang->mdio_active_low = pdata->mdio_active_low;
 
        new_bus = alloc_mdio_bitbang(&bitbang->ctrl);
        if (!new_bus)
include/linux/mdio-gpio.h +3 -0
index 7c9fe3c..57e57fe 100644
@@ -18,6 +18,9 @@ struct mdio_gpio_platform_data {
        unsigned int mdc;
        unsigned int mdio;
 
+       bool mdc_active_low;
+       bool mdio_active_low;
+
        unsigned int phy_mask;
        int irqs[PHY_MAX_ADDR];
        /* reset callback */

--
1.7.9.7

________________________________

This email and any files transmitted with it are confidential & proprietary to Systems and Software Enterprises, LLC. This information is intended solely for the use of the individual or entity to which it is addressed. Access or transmittal of the information contained in this e-mail, in full or in part, to any other organization or persons is not authorized.

Tested-by on v1 3/3
#11 lore raw

RE: [PATCH 3/3] net: mdio-gpio: Add support for separate MDI and MDO gpio pins

In reply to Guenter Roeck

This is for a system with fixed assignments of input and output pins (various variants of Kontron COMe).

---
 drivers/net/phy/mdio-gpio.c |   34 +++++++++++++++++++++++++++++++---
 include/linux/mdio-gpio.h   |    2 ++
 2 files changed, 33 insertions(+), 3 deletions(-)
drivers/net/phy/mdio-gpio.c +31 -3
index fac211a..9c4defd 100644
@@ -32,8 +32,8 @@
 
 struct mdio_gpio_info {
        struct mdiobb_ctrl ctrl;
-       int mdc, mdio;
-       int mdc_active_low, mdio_active_low;
+       int mdc, mdio, mdo;
+       int mdc_active_low, mdio_active_low, mdo_active_low;
 };
 
 static void *mdio_gpio_of_get_data(struct platform_device *pdev)
@@ -60,6 +60,12 @@ static void *mdio_gpio_of_get_data(struct platform_device *pdev)
        pdata->mdio = ret;
        pdata->mdio_active_low = flags & OF_GPIO_ACTIVE_LOW;
 
+       ret = of_get_gpio_flags(np, 2, &flags);
+       if (ret > 0) {
+               pdata->mdo = ret;
+               pdata->mdo_active_low = flags & OF_GPIO_ACTIVE_LOW;
+       }
+
        return pdata;
 }
 
@@ -68,6 +74,16 @@ static void mdio_dir(struct mdiobb_ctrl *ctrl, int dir)
        struct mdio_gpio_info *bitbang =
                container_of(ctrl, struct mdio_gpio_info, ctrl);
 
+       if (bitbang->mdo) {
+               /* Separate output pin. Always set its value to high
+                * when changing direction. If direction is input,
+                * assume the pin serves as pull-up. If direction is
+                * output, the default value is high.
+                */
+               gpio_set_value(bitbang->mdo, 1 ^ bitbang->mdo_active_low);
+               return;
+       }
+
        if (dir)
                gpio_direction_output(bitbang->mdio,
                                      1 ^ bitbang->mdio_active_low);
@@ -88,7 +104,10 @@ static void mdio_set(struct mdiobb_ctrl *ctrl, int what)
        struct mdio_gpio_info *bitbang =
                container_of(ctrl, struct mdio_gpio_info, ctrl);
 
-       gpio_set_value(bitbang->mdio, what ^ bitbang->mdio_active_low);
+       if (bitbang->mdo)
+               gpio_set_value(bitbang->mdo, what ^ bitbang->mdo_active_low);
+       else
+               gpio_set_value(bitbang->mdio, what ^ bitbang->mdio_active_low);
 }
 
 static void mdc_set(struct mdiobb_ctrl *ctrl, int what)
@@ -125,6 +144,8 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev,
        bitbang->mdc_active_low = pdata->mdc_active_low;
        bitbang->mdio = pdata->mdio;
        bitbang->mdio_active_low = pdata->mdio_active_low;
+       bitbang->mdo = pdata->mdo;
+       bitbang->mdo_active_low = pdata->mdo_active_low;
 
        new_bus = alloc_mdio_bitbang(&bitbang->ctrl);
        if (!new_bus)
@@ -151,6 +172,13 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev,
        if (devm_gpio_request(dev, bitbang->mdio, "mdio"))
                goto out_free_bus;
 
+       if (bitbang->mdo) {
+               if (devm_gpio_request(dev, bitbang->mdo, "mdo"))
+                       goto out_free_bus;
+               gpio_direction_output(bitbang->mdo, 1);
+               gpio_direction_input(bitbang->mdio);
+       }
+
        gpio_direction_output(bitbang->mdc, 0);
 
        dev_set_drvdata(dev, new_bus);
include/linux/mdio-gpio.h +2 -0
index 57e57fe..66c30a7 100644
@@ -17,9 +17,11 @@ struct mdio_gpio_platform_data {
        /* GPIO numbers for bus pins */
        unsigned int mdc;
        unsigned int mdio;
+       unsigned int mdo;
 
        bool mdc_active_low;
        bool mdio_active_low;
+       bool mdo_active_low;
 
        unsigned int phy_mask;
        int irqs[PHY_MAX_ADDR];

--
1.7.9.7

________________________________

This email and any files transmitted with it are confidential & proprietary to Systems and Software Enterprises, LLC. This information is intended solely for the use of the individual or entity to which it is addressed. Access or transmittal of the information contained in this e-mail, in full or in part, to any other organization or persons is not authorized.

Tested-by on v1 1/3
#2 lore raw

RE: [PATCH 1/3] net: mdio-gpio: Use devm_ functions where possible

In reply to Guenter Roeck

This simplifies error path and deinit/removal functions.

---
 drivers/net/phy/mdio-gpio.c |   19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)
drivers/net/phy/mdio-gpio.c +5 -14
index e701433..e853066 100644
@@ -110,7 +110,7 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev,
        struct mdio_gpio_info *bitbang;
        int i;
 
-       bitbang = kzalloc(sizeof(*bitbang), GFP_KERNEL);
+       bitbang = devm_kzalloc(dev, sizeof(*bitbang), GFP_KERNEL);
        if (!bitbang)
                goto out;
 
@@ -121,7 +121,7 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev,
 
        new_bus = alloc_mdio_bitbang(&bitbang->ctrl);
        if (!new_bus)
-               goto out_free_bitbang;
+               goto out;
 
        new_bus->name = "GPIO Bitbanged MDIO",
 
@@ -138,11 +138,11 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev,
 
        snprintf(new_bus->id, MII_BUS_ID_SIZE, "gpio-%x", bus_id);
 
-       if (gpio_request(bitbang->mdc, "mdc"))
+       if (devm_gpio_request(dev, bitbang->mdc, "mdc"))
                goto out_free_bus;
 
-       if (gpio_request(bitbang->mdio, "mdio"))
-               goto out_free_mdc;
+       if (devm_gpio_request(dev, bitbang->mdio, "mdio"))
+               goto out_free_bus;
 
        gpio_direction_output(bitbang->mdc, 0);
 
@@ -150,12 +150,8 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev,
 
        return new_bus;
 
-out_free_mdc:
-       gpio_free(bitbang->mdc);
 out_free_bus:
        free_mdio_bitbang(new_bus);
-out_free_bitbang:
-       kfree(bitbang);
 out:
        return NULL;
 }
@@ -163,13 +159,8 @@ out:
 static void mdio_gpio_bus_deinit(struct device *dev)
 {
        struct mii_bus *bus = dev_get_drvdata(dev);
-       struct mdio_gpio_info *bitbang = bus->priv;
 
-       dev_set_drvdata(dev, NULL);
-       gpio_free(bitbang->mdio);
-       gpio_free(bitbang->mdc);
        free_mdio_bitbang(bus);
-       kfree(bitbang);
 }
 
 static void mdio_gpio_bus_destroy(struct device *dev)

--
1.7.9.7

________________________________

This email and any files transmitted with it are confidential & proprietary to Systems and Software Enterprises, LLC. This information is intended solely for the use of the individual or entity to which it is addressed. Access or transmittal of the information contained in this e-mail, in full or in part, to any other organization or persons is not authorized.

maintainer
#3 lore raw

Re: [PATCH 1/3] net: mdio-gpio: Use devm_ functions where possible

From: Chris Healy <[email protected]>
Date: Wed, 16 Apr 2014 02:50:08 +0000

Quoted 4 lines

This simplifies error path and deinit/removal functions.

This isn't the way to add a Tested-by: tag of your own if that is what you're trying to do.

The proper way is to reply to the original patch, quote only the commit message, and then add your Tested-by: after the quoted material.

Tested-by on v1 1/3
#4 lore raw

RE: [PATCH 1/3] net: mdio-gpio: Use devm_ functions where possible

In reply to Guenter Roeck
Quoted 3 lines · Guenter Roeck

This simplifies error path and deinit/removal functions.

________________________________

This email and any files transmitted with it are confidential & proprietary to Systems and Software Enterprises, LLC. This information is intended solely for the use of the individual or entity to which it is addressed. Access or transmittal of the information contained in this e-mail, in full or in part, to any other organization or persons is not authorized.

Tested-by
#5 lore raw

RE: [PATCH 1/3] net: mdio-gpio: Use devm_ functions where possible

OK, I just sent it. Hopefully, I didn't mess it up again!

Do I need to do the same for 2/3 and 3/3?
________________________________________
From: Chris Healy
Sent: Wednesday, April 16, 2014 11:48 AM
To: Guenter Roeck; Florian Fainelli
Cc: [email protected]; [email protected]
Subject: RE: [PATCH 1/3] net: mdio-gpio: Use devm_ functions where possible

Quoted 3 lines · Guenter Roeck

This simplifies error path and deinit/removal functions.

________________________________

This email and any files transmitted with it are confidential & proprietary to Systems and Software Enterprises, LLC. This information is intended solely for the use of the individual or entity to which it is addressed. Access or transmittal of the information contained in this e-mail, in full or in part, to any other organization or persons is not authorized.

maintainer
#12 lore raw
In reply to Guenter Roeck

From: Guenter Roeck <[email protected]>
Date: Tue, 15 Apr 2014 19:16:39 -0700

Quoted 3 lines

The following series of patches adds support for active-low gpio pins as well as for systems with separate MDI and MDO pins to the mdio-gpio driver.

Series applied, thanks.

#6 lore raw

Re: [PATCH 1/3] net: mdio-gpio: Use devm_ functions where possible

In reply to Chris Healy
Quoted 3 lines · Chris Healy

OK, I just sent it. Hopefully, I didn't mess it up again!

Do I need to do the same for 2/3 and 3/3?

Hi Chris,

David just sent an e-mail that he accepted the series, so the answer is no.

Guenter

#7 lore raw

Re: [PATCH 1/3] net: mdio-gpio: Use devm_ functions where possible

In reply to Guenter Roeck

Hello.

Quoted 12 lines · Guenter Roeck

This simplifies error path and deinit/removal functions.

---
  drivers/net/phy/mdio-gpio.c |   19 +++++--------------
  1 file changed, 5 insertions(+), 14 deletions(-)
drivers/net/phy/mdio-gpio.c +0 -0
index e701433..e853066 100644
@@ -110,7 +110,7 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev,

[...]

drivers/net/phy/mdio-gpio.c out: · line 168

Quoted 7 lines
drivers/net/phy/mdio-gpio.c +0 -2
@@ -163,13 +159,8 @@ out:
  static void mdio_gpio_bus_deinit(struct device *dev)
  {
  	struct mii_bus *bus = dev_get_drvdata(dev);
-	struct mdio_gpio_info *bitbang = bus->priv;
 
-	dev_set_drvdata(dev, NULL);

You didn't even document this "drove-by" change. Ideally, it should have
been in a separate patch.

drivers/net/phy/mdio-gpio.c out: · line 164

Quoted 5 lines
drivers/net/phy/mdio-gpio.c +0 -3
-	gpio_free(bitbang->mdio);
-	gpio_free(bitbang->mdc);
  	free_mdio_bitbang(bus);
-	kfree(bitbang);
  }

WBR, Sergei