Skip to contentSkip to conversation

net: au1000_eth: fix PHY detection

PATCH Applied Manuel Lauss 2 participants 2 messages Jun 10, 2016 – Jun 11, 2016

Subsystems (2)

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: au1000_eth: fix PHY detection

Commit 7f854420fbfe9d49afe2ffb1df052cfe8e215541 ("phy: Add API for {un}registering an mdio device to a bus.") broke PHY detection on this driver with a copy-paste bug:
The code is looking 32 times for a PHY at address 0.

Fixes ethernet on AMD DB1100/DB1500/DB1550 boards which have their (autodetected) PHYs at address 31.

---
before:
libphy: au1000_eth_mii: probed
au1000-eth au1000-eth.0 (unnamed net_device) (uninitialized): no PHY found
au1000-eth: probe of au1000-eth.0 failed with error -1

after:
libphy: au1000_eth_mii: probed
AM79C874 au1000-eth-0:1f: attached PHY driver [AM79C874] (mii_bus:phy_addr=au1000-eth-0:1f, irq=-1) au1000-eth au1000-eth.0 eth0: Au1xx0 Ethernet found at 0x11500000, irq 36

 drivers/net/ethernet/amd/au1000_eth.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/net/ethernet/amd/au1000_eth.c +6 -7
index e0fb0f1..d8c77e8 100644
@@ -508,13 +508,12 @@ static int au1000_mii_probe(struct net_device *dev)
 	/* find the first (lowest address) PHY
 	 * on the current MAC's MII bus
 	 */
-	for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++)
-		if (mdiobus_get_phy(aup->mii_bus, aup->phy_addr)) {
-			phydev = mdiobus_get_phy(aup->mii_bus, aup->phy_addr);
-			if (!aup->phy_search_highest_addr)
-				/* break out with first one found */
-				break;
-		}
+	for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) {
+		phydev = mdiobus_get_phy(aup->mii_bus, phy_addr);
+		if (phydev && !aup->phy_search_highest_addr)
+			/* break out with first one found */
+			break;
+	}
 
 	if (aup->phy1_search_mac0) {
 		/* try harder to find a PHY */
Signature · 1 line
2.8.4
maintainer Applied
#1 lore raw

From: Manuel Lauss <[email protected]>
Date: Fri, 10 Jun 2016 16:53:05 +0200

Quoted 10 lines

Commit 7f854420fbfe9d49afe2ffb1df052cfe8e215541 ("phy: Add API for {un}registering an mdio device to a bus.") broke PHY detection on this driver with a copy-paste bug:
The code is looking 32 times for a PHY at address 0.

Fixes ethernet on AMD DB1100/DB1500/DB1550 boards which have their (autodetected) PHYs at address 31.

Applied.