RE: [PATCH] lan78xx: Connect phy early
From: Nisar.Sayed
Date: Thu Mar 15 2018 - 03:36:36 EST
Hi Alexander,
Thanks for the patch.
> @@ -2575,13 +2571,7 @@ 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;
>
> clear_bit(EVENT_DEV_OPEN, &dev->flags);
> netif_stop_queue(net);
Please do add valid "phydev" check before phy_stop, since "phy_disconnect" should be called before "unregister_netdev"
+ if (net->phydev)
phy_stop(net->phydev);
> @@ -3481,6 +3471,11 @@ static void lan78xx_disconnect(struct
> usb_interface *intf)
> net = dev->net;
> unregister_netdev(net);
>
> + phy_unregister_fixup_for_uid(PHY_KSZ9031RNX, 0xfffffff0);
> + phy_unregister_fixup_for_uid(PHY_LAN8835, 0xfffffff0);
> +
> + phy_disconnect(net->phydev);
> +
> cancel_delayed_work_sync(&dev->wq);
>
> usb_scuttle_anchored_urbs(&dev->deferred);
Please move "unregister_netdev" after "phy_disconnect", otherwise "phy_disconnect" will fail while we disconnect USB.
> @@ -3634,6 +3629,10 @@ 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)
> + return ret;
> +
> return 0;
>
> out3:
> --
> 2.12.3
We should "goto out4" instead of "return" upon "lan78xx_phy_init" fail
+ out4:
+ unregister_netdev(netdev);
In addition to current changes, you might have to take care of the following.
In function "lan78xx_reset_resume"
- lan78xx_phy_init(dev);
+ phy_start(dev->net->phydev);
Thanks,
Sd.Nisar