phy: fixed: Fix removal of phys.
[deliverable/linux.git] / net / dsa / dsa.c
index fa4daba8db55c7297b80499b0fb96c60fb096322..c28c47463b7edfc58b08e2d059e0e69b66a3fff7 100644 (file)
@@ -430,35 +430,30 @@ 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 (!(dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, 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++) {
                port_dn = cd->port_dn[port];
                if (of_phy_is_fixed_link(port_dn)) {
                        phydev = of_phy_find_device(port_dn);
                        if (phydev) {
-                               int addr = phydev->mdio.addr;
-
                                phy_device_free(phydev);
                                of_node_put(port_dn);
-                               fixed_phy_del(addr);
+                               fixed_phy_unregister(phydev);
                        }
                }
        }
 
-       /* 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);
 }
 
@@ -935,6 +930,14 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)
 {
        int i;
 
+       dst->master_netdev->dsa_ptr = NULL;
+
+       /* If we used a tagging format that doesn't have an ethertype
+        * field, make sure that all packets from this point get sent
+        * without the tag and go through the regular receive path.
+        */
+       wmb();
+
        for (i = 0; i < dst->pd->nr_chips; i++) {
                struct dsa_switch *ds = dst->ds[i];
 
@@ -988,14 +991,6 @@ static int dsa_suspend(struct device *d)
        struct dsa_switch_tree *dst = platform_get_drvdata(pdev);
        int i, ret = 0;
 
-       dst->master_netdev->dsa_ptr = NULL;
-
-       /* If we used a tagging format that doesn't have an ethertype
-        * field, make sure that all packets from this point get sent
-        * without the tag and go through the regular receive path.
-        */
-       wmb();
-
        for (i = 0; i < dst->pd->nr_chips; i++) {
                struct dsa_switch *ds = dst->ds[i];
 
This page took 0.07789 seconds and 5 git commands to generate.