OSDN Git Service

net: phy: clean up cortina workaround
authorRussell King <rmk+kernel@armlinux.org.uk>
Thu, 18 Jun 2020 13:45:32 +0000 (14:45 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sat, 20 Jun 2020 03:17:14 +0000 (20:17 -0700)
Move the Cortina PHY workaround out of the "devices in package" loop;
it doesn't need to be in there as the control flow will terminate the
loop once we enter the workaround irrespective of the workaround's
outcome. The workaround is triggered by the ID being mostly 1's, which
will in any case terminate the loop.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/phy_device.c

index 04946de..c71dc26 100644 (file)
@@ -720,23 +720,21 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id,
                phy_reg = get_phy_c45_devs_in_pkg(bus, addr, i, devs);
                if (phy_reg < 0)
                        return -EIO;
+       }
+
+       if ((*devs & 0x1fffffff) == 0x1fffffff) {
+               /* If mostly Fs, there is no device there, then let's probe
+                * MMD 0, as some 10G PHYs have zero Devices In package,
+                * e.g. Cortina CS4315/CS4340 PHY.
+                */
+               phy_reg = get_phy_c45_devs_in_pkg(bus, addr, 0, devs);
+               if (phy_reg < 0)
+                       return -EIO;
 
+               /* no device there, let's get out of here */
                if ((*devs & 0x1fffffff) == 0x1fffffff) {
-                       /*  If mostly Fs, there is no device there,
-                        *  then let's continue to probe more, as some
-                        *  10G PHYs have zero Devices In package,
-                        *  e.g. Cortina CS4315/CS4340 PHY.
-                        */
-                       phy_reg = get_phy_c45_devs_in_pkg(bus, addr, 0, devs);
-                       if (phy_reg < 0)
-                               return -EIO;
-                       /* no device there, let's get out of here */
-                       if ((*devs & 0x1fffffff) == 0x1fffffff) {
-                               *phy_id = 0xffffffff;
-                               return 0;
-                       } else {
-                               break;
-                       }
+                       *phy_id = 0xffffffff;
+                       return 0;
                }
        }