diff mbox

net: of_mdio: fix behavior on missing phy device

Message ID 1367920171-20264-1-git-send-email-sebastian.hesselbarth@gmail.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Sebastian Hesselbarth May 7, 2013, 9:49 a.m. UTC
of_mdiobus_register creates a phy_device even if get_phy_device failed
to create it previously. This causes indefinite polling on non-existent
PHYs. This fix makes of_mdio_register rely on get_phy_device to
properly create the device or fail otherwise.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
---
Cc: Grant Likely <grant.likely@linaro.org>
Cc: Rob Herring <rob.herring@calxeda.com>
Cc: David Miller <davem@davemloft.net>
Cc: devicetree-discuss@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org
Cc: netdev@vger.kernel.org
---
 drivers/of/of_mdio.c |   11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

Comments

Sergei Shtylyov May 7, 2013, 5:55 p.m. UTC | #1
Hello.

On 07-05-2013 13:49, Sebastian Hesselbarth wrote:

> of_mdiobus_register creates a phy_device even if get_phy_device failed
> to create it previously. This causes indefinite polling on non-existent
> PHYs. This fix makes of_mdio_register rely on get_phy_device to
> properly create the device or fail otherwise.

> Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
> ---
> Cc: Grant Likely <grant.likely@linaro.org>
> Cc: Rob Herring <rob.herring@calxeda.com>
> Cc: David Miller <davem@davemloft.net>
> Cc: devicetree-discuss@lists.ozlabs.org
> Cc: linux-kernel@vger.kernel.org
> Cc: netdev@vger.kernel.org
> ---
>   drivers/of/of_mdio.c |   11 ++++-------
>   1 file changed, 4 insertions(+), 7 deletions(-)

> diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
> index 23049ae..d5a57a9 100644
> --- a/drivers/of/of_mdio.c
> +++ b/drivers/of/of_mdio.c
> @@ -84,13 +84,10 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
>   		phy = get_phy_device(mdio, addr, is_c45);
>

    This empty line is not needed -- would be good to drop it, while at 
this.

>   		if (!phy || IS_ERR(phy)) {
> -			phy = phy_device_create(mdio, addr, 0, false, NULL);
> -			if (!phy || IS_ERR(phy)) {
> -				dev_err(&mdio->dev,
> -					"error creating PHY at address %i\n",
> -					addr);
> -				continue;
> -			}
> +			dev_err(&mdio->dev,
> +				"cannot get PHY at address %i\n",
> +				addr);
> +			continue;
>   		}
>
>   		/* Associate the OF node with the device structure so it
>

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller May 8, 2013, 8:14 p.m. UTC | #2
From: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Date: Tue,  7 May 2013 11:49:31 +0200

> of_mdiobus_register creates a phy_device even if get_phy_device failed
> to create it previously. This causes indefinite polling on non-existent
> PHYs. This fix makes of_mdio_register rely on get_phy_device to
> properly create the device or fail otherwise.
> 
> Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index 23049ae..d5a57a9 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -84,13 +84,10 @@  int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
 		phy = get_phy_device(mdio, addr, is_c45);
 
 		if (!phy || IS_ERR(phy)) {
-			phy = phy_device_create(mdio, addr, 0, false, NULL);
-			if (!phy || IS_ERR(phy)) {
-				dev_err(&mdio->dev,
-					"error creating PHY at address %i\n",
-					addr);
-				continue;
-			}
+			dev_err(&mdio->dev,
+				"cannot get PHY at address %i\n",
+				addr);
+			continue;
 		}
 
 		/* Associate the OF node with the device structure so it