lan78xx: Connect phy early
[linux-2.6-microblaze.git] / drivers / net / usb / lan78xx.c
index 55a78eb..aff105f 100644 (file)
@@ -2082,10 +2082,6 @@ static int lan78xx_phy_init(struct lan78xx_net *dev)
 
        dev->fc_autoneg = phydev->autoneg;
 
-       phy_start(phydev);
-
-       netif_dbg(dev, ifup, dev->net, "phy initialised successfully");
-
        return 0;
 
 error:
@@ -2522,9 +2518,9 @@ static int lan78xx_open(struct net_device *net)
        if (ret < 0)
                goto done;
 
-       ret = lan78xx_phy_init(dev);
-       if (ret < 0)
-               goto done;
+       phy_start(net->phydev);
+
+       netif_dbg(dev, ifup, dev->net, "phy initialised successfully");
 
        /* for Link Check */
        if (dev->urb_intr) {
@@ -2585,13 +2581,8 @@ static int lan78xx_stop(struct net_device *net)
        if (timer_pending(&dev->stat_monitor))
                del_timer_sync(&dev->stat_monitor);
 
-       phy_unregister_fixup_for_uid(PHY_KSZ9031RNX, 0xfffffff0);
-       phy_unregister_fixup_for_uid(PHY_LAN8835, 0xfffffff0);
-
-       phy_stop(net->phydev);
-       phy_disconnect(net->phydev);
-
-       net->phydev = NULL;
+       if (net->phydev)
+               phy_stop(net->phydev);
 
        clear_bit(EVENT_DEV_OPEN, &dev->flags);
        netif_stop_queue(net);
@@ -3506,8 +3497,13 @@ static void lan78xx_disconnect(struct usb_interface *intf)
                return;
 
        udev = interface_to_usbdev(intf);
-
        net = dev->net;
+
+       phy_unregister_fixup_for_uid(PHY_KSZ9031RNX, 0xfffffff0);
+       phy_unregister_fixup_for_uid(PHY_LAN8835, 0xfffffff0);
+
+       phy_disconnect(net->phydev);
+
        unregister_netdev(net);
 
        cancel_delayed_work_sync(&dev->wq);
@@ -3663,8 +3659,14 @@ static int lan78xx_probe(struct usb_interface *intf,
        pm_runtime_set_autosuspend_delay(&udev->dev,
                                         DEFAULT_AUTOSUSPEND_DELAY);
 
+       ret = lan78xx_phy_init(dev);
+       if (ret < 0)
+               goto out4;
+
        return 0;
 
+out4:
+       unregister_netdev(netdev);
 out3:
        lan78xx_unbind(dev, intf);
 out2:
@@ -4012,7 +4014,7 @@ static int lan78xx_reset_resume(struct usb_interface *intf)
 
        lan78xx_reset(dev);
 
-       lan78xx_phy_init(dev);
+       phy_start(dev->net->phydev);
 
        return lan78xx_resume(intf);
 }