dsa: Destroy fixed link phys after the phy has been disconnected
authorAndrew Lunn <andrew@lunn.ch>
Fri, 11 Mar 2016 23:01:38 +0000 (00:01 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 14 Mar 2016 19:43:11 +0000 (15:43 -0400)
The phy is disconnected from the slave in dsa_slave_destroy(). Don't
destroy fixed link phys until after this, since there can be fixed
linked phys connected to ports.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/dsa/dsa.c

index d8fb47f..1018e7d 100644 (file)
@@ -430,7 +430,18 @@ static void dsa_switch_destroy(struct dsa_switch *ds)
                hwmon_device_unregister(ds->hwmon_dev);
 #endif
 
-       /* Disable configuration of the CPU and DSA ports */
+       /* Destroy network devices for physical switch ports. */
+       for (port = 0; port < DSA_MAX_PORTS; port++) {
+               if (!(ds->phys_port_mask & (1 << port)))
+                       continue;
+
+               if (!ds->ports[port])
+                       continue;
+
+               dsa_slave_destroy(ds->ports[port]);
+       }
+
+       /* Remove any fixed link PHYs */
        for (port = 0; port < DSA_MAX_PORTS; port++) {
                if (!(dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)))
                        continue;
@@ -448,17 +459,6 @@ static void dsa_switch_destroy(struct dsa_switch *ds)
                }
        }
 
-       /* Destroy network devices for physical switch ports. */
-       for (port = 0; port < DSA_MAX_PORTS; port++) {
-               if (!(ds->phys_port_mask & (1 << port)))
-                       continue;
-
-               if (!ds->ports[port])
-                       continue;
-
-               dsa_slave_destroy(ds->ports[port]);
-       }
-
        mdiobus_unregister(ds->slave_mii_bus);
 }