Re: [PATCH net-next 1/2] net: phy: Support set_loopback override
From: Andrew Lunn <andrew@lunn.ch>
Date: 2021-08-18 21:20:29
I saw only 4 references for to_phy_driver(): - phy_loopback() of course - phy_probe() which uses it to initialize phydev->drv 3 lines later
This is correct. The driver core will set dev.driver to what it thinks is the correct driver to use, before calling probe.
- mdio_bus_phy_may_suspend() which checks only for valid suspend function pointer, but later phy_suspend() uses phydev->drv, so this is at least inconsistent
I guess the real question here is, can a device be suspended before it is probed? It would seem rather odd. So i expect phydev->drv is safe to use.
- phy_bus_match() which casts from struct device_driver to struct phy_driver
This is used by the driver core when trying to find a matching driver. So it is used before phy_probe(). So this is correct.
phydev->drv is used much more often and seems to be the right way. I suggest to also fix mdio_bus_phy_may_suspend(). phy_probe() and phy_bus_match() are valid uses, because phydev->drv is not available for them. Do you agree?
Agreed. Thanks for spending the time to look at this. I was expecting there to be more problems than just loopback. Andrew