dsa: Register netdev before phy
authorAndrew Lunn <andrew@lunn.ch>
Wed, 6 Jan 2016 19:11:20 +0000 (20:11 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 7 Jan 2016 19:31:26 +0000 (14:31 -0500)
When the phy is connected, an info message is printed. If the netdev
it is attached to has not been registered yet, the name
'uninitialised' in the output. By registering the netdev first, then
connecting they phy, we can avoid this.

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

index 2771713..40b9ca7 100644 (file)
@@ -1189,13 +1189,6 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
        p->old_link = -1;
        p->old_duplex = -1;
 
-       ret = dsa_slave_phy_setup(p, slave_dev);
-       if (ret) {
-               netdev_err(master, "error %d setting up slave phy\n", ret);
-               free_netdev(slave_dev);
-               return ret;
-       }
-
        ds->ports[port] = slave_dev;
        ret = register_netdev(slave_dev);
        if (ret) {
@@ -1209,6 +1202,13 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
 
        netif_carrier_off(slave_dev);
 
+       ret = dsa_slave_phy_setup(p, slave_dev);
+       if (ret) {
+               netdev_err(master, "error %d setting up slave phy\n", ret);
+               free_netdev(slave_dev);
+               return ret;
+       }
+
        return 0;
 }