Re: [PATCH net-next v5 2/6] net: usb: lan78xx: Convert to PHYlink for improved PHY and MAC management

Russell King (Oracle)
2025-03-25T18:27:07Z

On Tue, Mar 25, 2025 at 05:37:53PM +0000, Rengarajan.S@microchip.com wrote:
> Hi Oleksji,
>
> On Wed, 2025-03-19 at 09:49 +0100, Oleksij Rempel wrote:
> > udev = interface_to_usbdev(intf);
> > net = dev->net;
> >
> > + rtnl_lock();
> > + phylink_stop(dev->phylink);
> > + phylink_disconnect_phy(dev->phylink);
> > + rtnl_unlock();
> > +
> > + netif_napi_del(&dev->napi);
> > +
> > unregister_netdev(net);
> >
> > timer_shutdown_sync(&dev->stat_monitor);
> > set_bit(EVENT_DEV_DISCONNECT, &dev->flags);
> > cancel_delayed_work_sync(&dev->wq);
> >
> > - phydev = net->phydev;
> > -
> > - phy_disconnect(net->phydev);
> > -
> > - if (phy_is_pseudo_fixed_link(phydev)) {
> > - fixed_phy_unregister(phydev);
> > - phy_device_free(phydev);
> > - }
> > + phylink_destroy(dev->phylink);
>
> Before destroying phylink here is it possible to add a check to make
> sure dev->phylink is allocated properly.

Not necessary.

How would dev->phylink not be "allocated properly" ?

If it isn't "allocated properly" then lan78xx_phylink_setup() will
return an error, which will cause lan78xx_probe() to fail. If the
probe function fails, then the driver won't be bound.

Having additional nonsense checks for things that shouldn't ever
happen is annying and detracts from code readability.

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!