[PATCH 6/9] net: phy: move phy_init_hw to phy_device_connect

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


This is needed when a phy gets registered outsize of phy_device_connect
but has to be attached to an ethernet device later.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/net/phy/mdio_bus.c | 8 --------
 drivers/net/phy/phy.c      | 9 +++++++++
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index b0fbf2d..84c05ad 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -181,14 +181,6 @@ static int mdio_bus_probe(struct device_d *_dev)
 	dev->supported = drv->features;
 	dev->advertising = drv->features;
 
-	ret = phy_init_hw(dev);
-	if (ret)
-		goto err;
-
-	/* Sanitize settings based on PHY capabilities */
-	if ((dev->supported & SUPPORTED_Autoneg) == 0)
-		dev->autoneg = AUTONEG_DISABLE;
-
 	dev_add_param_int_ro(&dev->dev, "phy_addr", dev->addr, "%d");
 	dev_add_param_int_ro(&dev->dev, "phy_id", dev->phy_id, "0x%08x");
 
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 74ef3d9..b05a313 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -306,6 +306,15 @@ int phy_device_connect(struct eth_device *edev, struct mii_bus *bus, int addr,
 
 	edev->phydev = dev;
 	dev->attached_dev = edev;
+
+	ret = phy_init_hw(dev);
+	if (ret)
+		goto fail;
+
+	/* Sanitize settings based on PHY capabilities */
+	if ((dev->supported & SUPPORTED_Autoneg) == 0)
+		dev->autoneg = AUTONEG_DISABLE;
+
 	phy_config_aneg(edev->phydev);
 
 	dev->adjust_link = adjust_link;
-- 
1.8.5.1




More information about the barebox mailing list