[PATCH 3/9] net: phy: move duplicated code out of if/else

Sascha Hauer s.hauer at pengutronix.de
Wed Dec 11 06:41:11 EST 2013


Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/net/phy/phy.c | 27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index a83b35c..fb4cb11 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -269,13 +269,6 @@ int phy_device_connect(struct eth_device *edev, struct mii_bus *bus, int addr,
 			ret = -EIO;
 			goto fail;
 		}
-
-		dev->interface = interface;
-		dev->dev_flags = flags;
-
-		ret = phy_register_device(dev);
-		if (ret)
-			goto fail;
 	} else {
 		for (i = 0; i < PHY_MAX_ADDR && !edev->phydev; i++) {
 			/* skip masked out PHY addresses */
@@ -283,20 +276,18 @@ int phy_device_connect(struct eth_device *edev, struct mii_bus *bus, int addr,
 				continue;
 
 			dev = mdiobus_scan(bus, i);
-			if (IS_ERR(dev) || dev->attached_dev)
-				continue;
-
-			dev->interface = interface;
-			dev->dev_flags = flags;
-
-			ret = phy_register_device(dev);
-			if (ret)
-				goto fail;
-
-			break;
+			if (!IS_ERR(dev) && !dev->attached_dev)
+                                break;
 		}
 	}
 
+	dev->interface = interface;
+	dev->dev_flags = flags;
+
+	ret = phy_register_device(dev);
+	if (ret)
+		goto fail;
+
 	edev->phydev = dev;
 	dev->attached_dev = edev;
 	phy_config_aneg(edev->phydev);
-- 
1.8.5.1




More information about the barebox mailing list