Re: [RFC PATCH net] Revert "net: phy: Uniform PHY driver access"

From: Gerhard Engleder
Date: Sun Sep 12 2021 - 16:49:40 EST


> This reverts commit 3ac8eed62596387214869319379c1fcba264d8c6.
>
> I am not actually sure I follow the patch author's logic, because the
> change does more than it says on the box, but this patch breaks
> suspend/resume on NXP LS1028A and probably on any other systems which
> have PHY devices with no driver bound, because the patch has removed the
> "!phydev->drv" check without actually explaining why that is fine.

The wrong assumption was that the driver is set for every device during probe
before suspend. Intention of the patch was only clean up of
to_phy_driver() usage.

> static bool mdio_bus_phy_may_suspend(struct phy_device *phydev)
> {
> + struct device_driver *drv = phydev->mdio.dev.driver;
> + struct phy_driver *phydrv = to_phy_driver(drv);
> struct net_device *netdev = phydev->attached_dev;
>
> - if (!phydev->drv->suspend)
> + if (!drv || !phydrv->suspend)
> return false;
>
> /* PHY not attached? May suspend if the PHY has not already been

I suggest to add the "!phydev->drv" check, but others may know it
better than me.

Gerhard