Re: [PATCH net-next v1 3/7] net: usb: lan78xx: Improve error handling for PHY init path

Russell King (Oracle)
2025-01-08T12:52:48Z

On Wed, Jan 08, 2025 at 01:13:37PM +0100, Oleksij Rempel wrote:
> phydev = phy_find_first(dev->mdiobus);
> if (!phydev) {
> netdev_dbg(dev->net, "PHY Not Found!! Registering Fixed PHY\n");
> phydev = fixed_phy_register(PHY_POLL, &fphy_status, NULL);
> - if (IS_ERR(phydev)) {
> + if (PTR_ERR_OR_ZERO(phydev)) {

Even though I've said to use phylink's fixed-phy support, I'm wondering
about this entire hunk.

> netdev_err(dev->net, "No PHY/fixed_PHY found\n");
> - return NULL;
> + if (IS_ERR(phydev))
> + return phydev;
> + else
> + return ERR_PTR(-ENODEV);

When does fixed_phy_register() return NULL?

If there's no fixed-phy support enabled, then you get an ENODEV error
pointer. If support is enabled, then you may get an error pointer
or a valid phy_device structure. I can't see any case where it returns
NULL. So, I think this hunk is redundant.

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