[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z-L1ap2HNc7apxHd@shell.armlinux.org.uk>
Date: Tue, 25 Mar 2025 18:26:50 +0000
From: "Russell King (Oracle)" <linux@...linux.org.uk>
To: Rengarajan.S@...rochip.com
Cc: andrew+netdev@...n.ch, davem@...emloft.net, Thangaraj.S@...rochip.com,
Woojung.Huh@...rochip.com, pabeni@...hat.com,
o.rempel@...gutronix.de, edumazet@...gle.com, kuba@...nel.org,
phil@...pberrypi.org, kernel@...gutronix.de, horms@...nel.org,
linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
UNGLinuxDriver@...rochip.com, maxime.chevallier@...tlin.com
Subject: Re: [PATCH net-next v5 2/6] net: usb: lan78xx: Convert to PHYlink
for improved PHY and MAC management
On Tue, Mar 25, 2025 at 05:37:53PM +0000, Rengarajan.S@...rochip.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!
Powered by blists - more mailing lists