net: dsa: lan9303: Fix lan9303_detect_phy_setup() for MDIO
authorEgil Hjelmeland <[email protected]>
Sun, 30 Jul 2017 17:58:53 +0000 (19:58 +0200)
committerDavid S. Miller <[email protected]>
Mon, 31 Jul 2017 02:23:29 +0000 (19:23 -0700)
Handle that MDIO read with no response return 0xffff.

Signed-off-by: Egil Hjelmeland <[email protected]>
Reviewed-by: Andrew Lunn <[email protected]>
Reviewed-by: Vivien Didelot <[email protected]>
Reviewed-by: Florian Fainelli <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
drivers/net/dsa/lan9303-core.c

index cd76e61f1fca722e33f6387c293b4b85e239a5a2..9d0ab77edb4ae2630830026b642d2003e8020a15 100644 (file)
@@ -427,6 +427,7 @@ static int lan9303_detect_phy_setup(struct lan9303 *chip)
         * Special reg 18 of phy 3 reads as 0x0000, if 'phy_addr_sel_strap' is 0
         * and the IDs are 0-1-2, else it contains something different from
         * 0x0000, which means 'phy_addr_sel_strap' is 1 and the IDs are 1-2-3.
+        * 0xffff is returned on MDIO read with no response.
         */
        reg = lan9303_port_phy_reg_read(chip, 3, MII_LAN911X_SPECIAL_MODES);
        if (reg < 0) {
@@ -434,7 +435,7 @@ static int lan9303_detect_phy_setup(struct lan9303 *chip)
                return reg;
        }
 
-       if (reg != 0)
+       if ((reg != 0) && (reg != 0xffff))
                chip->phy_addr_sel_strap = 1;
        else
                chip->phy_addr_sel_strap = 0;