[source] generic: ar8216: improve ar8xxx_is_possible check

LEDE Commits lede-commits at lists.infradead.org
Sat Oct 15 02:37:10 PDT 2016


blogic pushed a commit to source.git, branch master:
https://git.lede-project.org/e9455c561d4af68840421e3d442e4ad5ebfbedc6

commit e9455c561d4af68840421e3d442e4ad5ebfbedc6
Author: Christian Lamparter <chunkeey at googlemail.com>
AuthorDate: Wed Oct 5 15:19:34 2016 +0200

    generic: ar8216: improve ar8xxx_is_possible check
    
    The commit "generic: ar8216: add sanity check to ar8216_probe"
    (774da6c7a40320a320b28d71291c0e61fcf7bc8a) stated that PHY IDs
    should be checked at address 0-4. However, the PHY 4 was
    never check by the loop. This patch extends the check to be
    similar to the Atheors SDK. It tries all 4 ports and skips
    unconnected PHYs if necessary. If it cannot find any familiar
    PHYs, it will prevent the phy driver from initializing.
    
    This patch is necessary for the C-60. It doesn't have a
    PHY at port 3, so this caused the check in ar8xxx_is_possible
    to fail. As a result, the ethernet ports on the C-60 didn't
    work.
    
    Signed-off-by: Christian Lamparter <chunkeey at gmail.com>
---
 target/linux/generic/files/drivers/net/phy/ar8216.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.c b/target/linux/generic/files/drivers/net/phy/ar8216.c
index 70f4774..cd5fbac 100644
--- a/target/linux/generic/files/drivers/net/phy/ar8216.c
+++ b/target/linux/generic/files/drivers/net/phy/ar8216.c
@@ -2113,21 +2113,21 @@ ar8xxx_phy_match(u32 phy_id)
 static bool
 ar8xxx_is_possible(struct mii_bus *bus)
 {
-	unsigned i;
+	unsigned int i, found_phys = 0;
 
-	for (i = 0; i < 4; i++) {
+	for (i = 0; i < 5; i++) {
 		u32 phy_id;
 
 		phy_id = mdiobus_read(bus, i, MII_PHYSID1) << 16;
 		phy_id |= mdiobus_read(bus, i, MII_PHYSID2);
-		if (!ar8xxx_phy_match(phy_id)) {
+		if (ar8xxx_phy_match(phy_id)) {
+			found_phys++;
+		} else if (phy_id) {
 			pr_debug("ar8xxx: unknown PHY at %s:%02x id:%08x\n",
 				 dev_name(&bus->dev), i, phy_id);
-			return false;
 		}
 	}
-
-	return true;
+	return !!found_phys;
 }
 
 static int



More information about the lede-commits mailing list