linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Re: [RFC/PATCH] net: Rework mdio-ofgpio driver to use of_mdio infrastructure
       [not found] <4A646117.1030409@elphinstone.net>
@ 2009-07-20 14:59 ` Grant Likely
  2009-07-21  9:50   ` [PATCH v2] " Mark Ware
  0 siblings, 1 reply; 3+ messages in thread
From: Grant Likely @ 2009-07-20 14:59 UTC (permalink / raw)
  To: Mark Ware; +Cc: netdev, linuxppc-dev

(adding cc:linuxppc-dev@ozlabs.org)

On Mon, Jul 20, 2009 at 6:20 AM, Mark Ware<mware@elphinstone.net> wrote:
> Changes to the fs_enet driver (aa73832c5a80d6c52c69b18af858d88fa595dd3c)
> cause kernel crashes when using the mdio-ofgpio driver.
>
> The following patch is a fairly naive attempt to replicate similar change=
s
> made to the fs_enet mii-bitbang drivers.

For a naive attempt, it's really quite good.  However, I'd do it
slightly differently.

You should refactor mdio_gpio_bus_init() to not call
mdiobus_register() at all, and instead just return a pointer to the
unregistered new_bus.  Then mdio_gpio_probe() and mdio_ofgpio_probe()
can call the correct register variant directly.  Fewer ugly #ifdefs
this way.  It also eliminates the need to cast the void* pointer.

Thanks for catching this.

g.

> =A0drivers/net/phy/mdio-gpio.c | =A0 39 +++++++++++++--------------------=
------
> =A01 files changed, 13 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c
> index 33984b7..6568176 100644
> --- a/drivers/net/phy/mdio-gpio.c
> +++ b/drivers/net/phy/mdio-gpio.c
> @@ -30,6 +30,7 @@
>
> =A0#ifdef CONFIG_OF_GPIO
> =A0#include <linux/of_gpio.h>
> +#include <linux/of_mdio.h>
> =A0#include <linux/of_platform.h>
> =A0#endif
>
> @@ -83,7 +84,8 @@ static struct mdiobb_ops mdio_gpio_ops =3D {
>
> =A0static int __devinit mdio_gpio_bus_init(struct device *dev,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0struct mdio_gpio_platform_data
> *pdata,
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 int bus_id)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 int bus_id,
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0void *ofdev)
> =A0{
> =A0 =A0 =A0 =A0struct mii_bus *new_bus;
> =A0 =A0 =A0 =A0struct mdio_gpio_info *bitbang;
> @@ -129,7 +131,14 @@ static int __devinit mdio_gpio_bus_init(struct devic=
e
> *dev,
>
> =A0 =A0 =A0 =A0dev_set_drvdata(dev, new_bus);
>
> - =A0 =A0 =A0 ret =3D mdiobus_register(new_bus);
> +#ifdef CONFIG_OF_GPIO
> + =A0 =A0if (ofdev)
> + =A0 =A0 =A0 =A0ret =3D of_mdiobus_register(new_bus, ((struct of_device =
*)
> ofdev)->node);
> + =A0 =A0else
> +#else
> + =A0 =A0 =A0 =A0 =A0 ret =3D mdiobus_register(new_bus);
> +#endif
> +
> =A0 =A0 =A0 =A0if (ret)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0goto out_free_all;
>
> @@ -168,7 +177,7 @@ static int __devinit mdio_gpio_probe(struct
> platform_device *pdev)
> =A0 =A0 =A0 =A0if (!pdata)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return -ENODEV;
>
> - =A0 =A0 =A0 return mdio_gpio_bus_init(&pdev->dev, pdata, pdev->id);
> + =A0 =A0 =A0 return mdio_gpio_bus_init(&pdev->dev, pdata, pdev->id, NULL=
);
> =A0}
>
> =A0static int __devexit mdio_gpio_remove(struct platform_device *pdev)
> @@ -179,28 +188,10 @@ static int __devexit mdio_gpio_remove(struct
> platform_device *pdev)
> =A0}
>
> =A0#ifdef CONFIG_OF_GPIO
> -static void __devinit add_phy(struct mdio_gpio_platform_data *pdata,
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct device_n=
ode *np)
> -{
> - =A0 =A0 =A0 const u32 *data;
> - =A0 =A0 =A0 int len, id, irq;
> -
> - =A0 =A0 =A0 data =3D of_get_property(np, "reg", &len);
> - =A0 =A0 =A0 if (!data || len !=3D 4)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 return;
> -
> - =A0 =A0 =A0 id =3D *data;
> - =A0 =A0 =A0 pdata->phy_mask &=3D ~(1 << id);
> -
> - =A0 =A0 =A0 irq =3D of_irq_to_resource(np, 0, NULL);
> - =A0 =A0 =A0 if (irq)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 pdata->irqs[id] =3D irq;
> -}
>
> =A0static int __devinit mdio_ofgpio_probe(struct of_device *ofdev,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 const struct of_device_id *match)
> =A0{
> - =A0 =A0 =A0 struct device_node *np =3D NULL;
> =A0 =A0 =A0 =A0struct mdio_gpio_platform_data *pdata;
> =A0 =A0 =A0 =A0int ret;
>
> @@ -218,11 +209,7 @@ static int __devinit mdio_ofgpio_probe(struct of_dev=
ice
> *ofdev,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto out_free;
> =A0 =A0 =A0 =A0pdata->mdio =3D ret;
>
> - =A0 =A0 =A0 while ((np =3D of_get_next_child(ofdev->node, np)))
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!strcmp(np->type, "ethernet-phy"))
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 add_phy(pdata, np);
> -
> - =A0 =A0 =A0 return mdio_gpio_bus_init(&ofdev->dev, pdata, pdata->mdc);
> + =A0 =A0 =A0 return mdio_gpio_bus_init(&ofdev->dev, pdata, pdata->mdc, o=
fdev);
>
> =A0out_free:
> =A0 =A0 =A0 =A0kfree(pdata);
> --
> 1.5.6.5
>



--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

* [PATCH v2] net: Rework mdio-ofgpio driver to use of_mdio infrastructure
  2009-07-20 14:59 ` [RFC/PATCH] net: Rework mdio-ofgpio driver to use of_mdio infrastructure Grant Likely
@ 2009-07-21  9:50   ` Mark Ware
  2009-07-21 17:09     ` Grant Likely
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Ware @ 2009-07-21  9:50 UTC (permalink / raw)
  To: Grant Likely, netdev, linuxppc-dev

Changes to the fs_enet driver (aa73832c5a80d6c52c69b18af858d88fa595dd3c) cause kernel crashes when using the mdio-ofgpio driver.

The following patch replicates similar changes made to the fs_enet mii-bitbang drivers.
---

This version attempts to address Grant's comments below:

Grant Likely wrote:
 >
 > You should refactor mdio_gpio_bus_init() to not call
 > mdiobus_register() at all, and instead just return a pointer to the
 > unregistered new_bus.  Then mdio_gpio_probe() and mdio_ofgpio_probe()
 > can call the correct register variant directly.  Fewer ugly #ifdefs
 > this way.  It also eliminates the need to cast the void* pointer.
 >

  drivers/net/phy/mdio-gpio.c |   77 ++++++++++++++++++++-----------------------
  1 files changed, 36 insertions(+), 41 deletions(-)

diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c
index 33984b7..22cdd45 100644
--- a/drivers/net/phy/mdio-gpio.c
+++ b/drivers/net/phy/mdio-gpio.c
@@ -30,6 +30,7 @@

  #ifdef CONFIG_OF_GPIO
  #include <linux/of_gpio.h>
+#include <linux/of_mdio.h>
  #include <linux/of_platform.h>
  #endif

@@ -81,13 +82,12 @@ static struct mdiobb_ops mdio_gpio_ops = {
  	.get_mdio_data = mdio_get,
  };

-static int __devinit mdio_gpio_bus_init(struct device *dev,
+static struct mii_bus * __devinit mdio_gpio_bus_init(struct device *dev,
  					struct mdio_gpio_platform_data *pdata,
  					int bus_id)
  {
  	struct mii_bus *new_bus;
  	struct mdio_gpio_info *bitbang;
-	int ret = -ENOMEM;
  	int i;

  	bitbang = kzalloc(sizeof(*bitbang), GFP_KERNEL);
@@ -104,8 +104,6 @@ static int __devinit mdio_gpio_bus_init(struct device *dev,

  	new_bus->name = "GPIO Bitbanged MDIO",

-	ret = -ENODEV;
-
  	new_bus->phy_mask = pdata->phy_mask;
  	new_bus->irq = pdata->irqs;
  	new_bus->parent = dev;
@@ -129,15 +127,8 @@ static int __devinit mdio_gpio_bus_init(struct device *dev,

  	dev_set_drvdata(dev, new_bus);

-	ret = mdiobus_register(new_bus);
-	if (ret)
-		goto out_free_all;
-
-	return 0;
+	return new_bus;

-out_free_all:
-	dev_set_drvdata(dev, NULL);
-	gpio_free(bitbang->mdio);
  out_free_mdc:
  	gpio_free(bitbang->mdc);
  out_free_bus:
@@ -145,30 +136,47 @@ out_free_bus:
  out_free_bitbang:
  	kfree(bitbang);
  out:
-	return ret;
+	return NULL;
  }

-static void __devexit mdio_gpio_bus_destroy(struct device *dev)
+static void __devinit mdio_gpio_bus_deinit(struct device *dev)
  {
  	struct mii_bus *bus = dev_get_drvdata(dev);
  	struct mdio_gpio_info *bitbang = bus->priv;

-	mdiobus_unregister(bus);
-	free_mdio_bitbang(bus);
  	dev_set_drvdata(dev, NULL);
-	gpio_free(bitbang->mdc);
  	gpio_free(bitbang->mdio);
+	gpio_free(bitbang->mdc);
+	free_mdio_bitbang(bus);
  	kfree(bitbang);
  }

+static void __devexit mdio_gpio_bus_destroy(struct device *dev)
+{
+	struct mii_bus *bus = dev_get_drvdata(dev);
+
+	mdiobus_unregister(bus);
+	mdio_gpio_bus_deinit(dev);
+}
+
  static int __devinit mdio_gpio_probe(struct platform_device *pdev)
  {
  	struct mdio_gpio_platform_data *pdata = pdev->dev.platform_data;
+	struct mii_bus *new_bus;
+	int ret;

  	if (!pdata)
  		return -ENODEV;

-	return mdio_gpio_bus_init(&pdev->dev, pdata, pdev->id);
+	new_bus = mdio_gpio_bus_init(&pdev->dev, pdata, pdev->id);
+	if (!new_bus)
+		return -ENODEV;
+
+	ret = mdiobus_register(new_bus);
+	if (ret)
+		mdio_gpio_bus_deinit(&pdev->dev);
+
+	return ret;
  }

  static int __devexit mdio_gpio_remove(struct platform_device *pdev)
@@ -179,29 +187,12 @@ static int __devexit mdio_gpio_remove(struct platform_device *pdev)
  }

  #ifdef CONFIG_OF_GPIO
-static void __devinit add_phy(struct mdio_gpio_platform_data *pdata,
-			      struct device_node *np)
-{
-	const u32 *data;
-	int len, id, irq;
-
-	data = of_get_property(np, "reg", &len);
-	if (!data || len != 4)
-		return;
-
-	id = *data;
-	pdata->phy_mask &= ~(1 << id);
-
-	irq = of_irq_to_resource(np, 0, NULL);
-	if (irq)
-		pdata->irqs[id] = irq;
-}

  static int __devinit mdio_ofgpio_probe(struct of_device *ofdev,
                                          const struct of_device_id *match)
  {
-	struct device_node *np = NULL;
  	struct mdio_gpio_platform_data *pdata;
+	struct mii_bus *new_bus;
  	int ret;

  	pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
@@ -215,14 +206,18 @@ static int __devinit mdio_ofgpio_probe(struct of_device *ofdev,

  	ret = of_get_gpio(ofdev->node, 1);
  	if (ret < 0)
-                goto out_free;
+		goto out_free;
  	pdata->mdio = ret;

-	while ((np = of_get_next_child(ofdev->node, np)))
-		if (!strcmp(np->type, "ethernet-phy"))
-			add_phy(pdata, np);
+	new_bus = mdio_gpio_bus_init(&ofdev->dev, pdata, pdata->mdc);
+	if (!new_bus)
+		return -ENODEV;

-	return mdio_gpio_bus_init(&ofdev->dev, pdata, pdata->mdc);
+	ret = of_mdiobus_register(new_bus, ofdev->node);
+	if (ret)
+		mdio_gpio_bus_deinit(&ofdev->dev);
+
+	return ret;

  out_free:
  	kfree(pdata);
-- 
1.5.6.5

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

* Re: [PATCH v2] net: Rework mdio-ofgpio driver to use of_mdio infrastructure
  2009-07-21  9:50   ` [PATCH v2] " Mark Ware
@ 2009-07-21 17:09     ` Grant Likely
  0 siblings, 0 replies; 3+ messages in thread
From: Grant Likely @ 2009-07-21 17:09 UTC (permalink / raw)
  To: Mark Ware; +Cc: netdev, David Miller, linuxppc-dev

On Tue, Jul 21, 2009 at 3:50 AM, Mark Ware<mware@elphinstone.net> wrote:
> Changes to the fs_enet driver (aa73832c5a80d6c52c69b18af858d88fa595dd3c)
> cause kernel crashes when using the mdio-ofgpio driver.
>
> The following patch replicates similar changes made to the fs_enet
> mii-bitbang drivers.

This looks good to me.  I've not tested it though (no hardware that
uses it).  You should specify the testing you've done in the commit
log.  Your signed-off-by: line is also missing.

Acked-by: Grant Likely <grant.likely@secretlab.ca>

David, once the above issues are solved, this one needs to be merged for 2.=
6.31.

Cheers,
g.

> ---
>
> This version attempts to address Grant's comments below:
>
> Grant Likely wrote:
>>
>> You should refactor mdio_gpio_bus_init() to not call
>> mdiobus_register() at all, and instead just return a pointer to the
>> unregistered new_bus. =A0Then mdio_gpio_probe() and mdio_ofgpio_probe()
>> can call the correct register variant directly. =A0Fewer ugly #ifdefs
>> this way. =A0It also eliminates the need to cast the void* pointer.
>>
>
> =A0drivers/net/phy/mdio-gpio.c | =A0 77
> ++++++++++++++++++++-----------------------
> =A01 files changed, 36 insertions(+), 41 deletions(-)
>
> diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c
> index 33984b7..22cdd45 100644
> --- a/drivers/net/phy/mdio-gpio.c
> +++ b/drivers/net/phy/mdio-gpio.c
> @@ -30,6 +30,7 @@
>
> =A0#ifdef CONFIG_OF_GPIO
> =A0#include <linux/of_gpio.h>
> +#include <linux/of_mdio.h>
> =A0#include <linux/of_platform.h>
> =A0#endif
>
> @@ -81,13 +82,12 @@ static struct mdiobb_ops mdio_gpio_ops =3D {
> =A0 =A0 =A0 =A0.get_mdio_data =3D mdio_get,
> =A0};
>
> -static int __devinit mdio_gpio_bus_init(struct device *dev,
> +static struct mii_bus * __devinit mdio_gpio_bus_init(struct device *dev,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0struct mdio_gpio_platform_data
> *pdata,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0int bus_id)
> =A0{
> =A0 =A0 =A0 =A0struct mii_bus *new_bus;
> =A0 =A0 =A0 =A0struct mdio_gpio_info *bitbang;
> - =A0 =A0 =A0 int ret =3D -ENOMEM;
> =A0 =A0 =A0 =A0int i;
>
> =A0 =A0 =A0 =A0bitbang =3D kzalloc(sizeof(*bitbang), GFP_KERNEL);
> @@ -104,8 +104,6 @@ static int __devinit mdio_gpio_bus_init(struct device
> *dev,
>
> =A0 =A0 =A0 =A0new_bus->name =3D "GPIO Bitbanged MDIO",
>
> - =A0 =A0 =A0 ret =3D -ENODEV;
> -
> =A0 =A0 =A0 =A0new_bus->phy_mask =3D pdata->phy_mask;
> =A0 =A0 =A0 =A0new_bus->irq =3D pdata->irqs;
> =A0 =A0 =A0 =A0new_bus->parent =3D dev;
> @@ -129,15 +127,8 @@ static int __devinit mdio_gpio_bus_init(struct devic=
e
> *dev,
>
> =A0 =A0 =A0 =A0dev_set_drvdata(dev, new_bus);
>
> - =A0 =A0 =A0 ret =3D mdiobus_register(new_bus);
> - =A0 =A0 =A0 if (ret)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto out_free_all;
> -
> - =A0 =A0 =A0 return 0;
> + =A0 =A0 =A0 return new_bus;
>
> -out_free_all:
> - =A0 =A0 =A0 dev_set_drvdata(dev, NULL);
> - =A0 =A0 =A0 gpio_free(bitbang->mdio);
> =A0out_free_mdc:
> =A0 =A0 =A0 =A0gpio_free(bitbang->mdc);
> =A0out_free_bus:
> @@ -145,30 +136,47 @@ out_free_bus:
> =A0out_free_bitbang:
> =A0 =A0 =A0 =A0kfree(bitbang);
> =A0out:
> - =A0 =A0 =A0 return ret;
> + =A0 =A0 =A0 return NULL;
> =A0}
>
> -static void __devexit mdio_gpio_bus_destroy(struct device *dev)
> +static void __devinit mdio_gpio_bus_deinit(struct device *dev)
> =A0{
> =A0 =A0 =A0 =A0struct mii_bus *bus =3D dev_get_drvdata(dev);
> =A0 =A0 =A0 =A0struct mdio_gpio_info *bitbang =3D bus->priv;
>
> - =A0 =A0 =A0 mdiobus_unregister(bus);
> - =A0 =A0 =A0 free_mdio_bitbang(bus);
> =A0 =A0 =A0 =A0dev_set_drvdata(dev, NULL);
> - =A0 =A0 =A0 gpio_free(bitbang->mdc);
> =A0 =A0 =A0 =A0gpio_free(bitbang->mdio);
> + =A0 =A0 =A0 gpio_free(bitbang->mdc);
> + =A0 =A0 =A0 free_mdio_bitbang(bus);
> =A0 =A0 =A0 =A0kfree(bitbang);
> =A0}
>
> +static void __devexit mdio_gpio_bus_destroy(struct device *dev)
> +{
> + =A0 =A0 =A0 struct mii_bus *bus =3D dev_get_drvdata(dev);
> +
> + =A0 =A0 =A0 mdiobus_unregister(bus);
> + =A0 =A0 =A0 mdio_gpio_bus_deinit(dev);
> +}
> +
> =A0static int __devinit mdio_gpio_probe(struct platform_device *pdev)
> =A0{
> =A0 =A0 =A0 =A0struct mdio_gpio_platform_data *pdata =3D pdev->dev.platfo=
rm_data;
> + =A0 =A0 =A0 struct mii_bus *new_bus;
> + =A0 =A0 =A0 int ret;
>
> =A0 =A0 =A0 =A0if (!pdata)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return -ENODEV;
>
> - =A0 =A0 =A0 return mdio_gpio_bus_init(&pdev->dev, pdata, pdev->id);
> + =A0 =A0 =A0 new_bus =3D mdio_gpio_bus_init(&pdev->dev, pdata, pdev->id)=
;
> + =A0 =A0 =A0 if (!new_bus)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENODEV;
> +
> + =A0 =A0 =A0 ret =3D mdiobus_register(new_bus);
> + =A0 =A0 =A0 if (ret)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 mdio_gpio_bus_deinit(&pdev->dev);
> +
> + =A0 =A0 =A0 return ret;
> =A0}
>
> =A0static int __devexit mdio_gpio_remove(struct platform_device *pdev)
> @@ -179,29 +187,12 @@ static int __devexit mdio_gpio_remove(struct
> platform_device *pdev)
> =A0}
>
> =A0#ifdef CONFIG_OF_GPIO
> -static void __devinit add_phy(struct mdio_gpio_platform_data *pdata,
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct device_n=
ode *np)
> -{
> - =A0 =A0 =A0 const u32 *data;
> - =A0 =A0 =A0 int len, id, irq;
> -
> - =A0 =A0 =A0 data =3D of_get_property(np, "reg", &len);
> - =A0 =A0 =A0 if (!data || len !=3D 4)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 return;
> -
> - =A0 =A0 =A0 id =3D *data;
> - =A0 =A0 =A0 pdata->phy_mask &=3D ~(1 << id);
> -
> - =A0 =A0 =A0 irq =3D of_irq_to_resource(np, 0, NULL);
> - =A0 =A0 =A0 if (irq)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 pdata->irqs[id] =3D irq;
> -}
>
> =A0static int __devinit mdio_ofgpio_probe(struct of_device *ofdev,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 const struct of_device_id *match)
> =A0{
> - =A0 =A0 =A0 struct device_node *np =3D NULL;
> =A0 =A0 =A0 =A0struct mdio_gpio_platform_data *pdata;
> + =A0 =A0 =A0 struct mii_bus *new_bus;
> =A0 =A0 =A0 =A0int ret;
>
> =A0 =A0 =A0 =A0pdata =3D kzalloc(sizeof(*pdata), GFP_KERNEL);
> @@ -215,14 +206,18 @@ static int __devinit mdio_ofgpio_probe(struct
> of_device *ofdev,
>
> =A0 =A0 =A0 =A0ret =3D of_get_gpio(ofdev->node, 1);
> =A0 =A0 =A0 =A0if (ret < 0)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0goto out_free;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto out_free;
> =A0 =A0 =A0 =A0pdata->mdio =3D ret;
>
> - =A0 =A0 =A0 while ((np =3D of_get_next_child(ofdev->node, np)))
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!strcmp(np->type, "ethernet-phy"))
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 add_phy(pdata, np);
> + =A0 =A0 =A0 new_bus =3D mdio_gpio_bus_init(&ofdev->dev, pdata, pdata->m=
dc);
> + =A0 =A0 =A0 if (!new_bus)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENODEV;
>
> - =A0 =A0 =A0 return mdio_gpio_bus_init(&ofdev->dev, pdata, pdata->mdc);
> + =A0 =A0 =A0 ret =3D of_mdiobus_register(new_bus, ofdev->node);
> + =A0 =A0 =A0 if (ret)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 mdio_gpio_bus_deinit(&ofdev->dev);
> +
> + =A0 =A0 =A0 return ret;
>
> =A0out_free:
> =A0 =A0 =A0 =A0kfree(pdata);
> --
> 1.5.6.5
>



--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

end of thread, other threads:[~2009-07-21 17:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <4A646117.1030409@elphinstone.net>
2009-07-20 14:59 ` [RFC/PATCH] net: Rework mdio-ofgpio driver to use of_mdio infrastructure Grant Likely
2009-07-21  9:50   ` [PATCH v2] " Mark Ware
2009-07-21 17:09     ` Grant Likely

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).