b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | From: Gabor Juhos <juhosg@openwrt.org> |
| 2 | Subject: generic: add detach callback to struct phy_driver |
| 3 | |
| 4 | lede-commit: fe61fc2d7d0b3fb348b502f68f98243b3ddf5867 |
| 5 | |
| 6 | Signed-off-by: Gabor Juhos <juhosg@openwrt.org> |
| 7 | --- |
| 8 | drivers/net/phy/phy_device.c | 3 +++ |
| 9 | include/linux/phy.h | 6 ++++++ |
| 10 | 2 files changed, 9 insertions(+) |
| 11 | |
| 12 | --- a/drivers/net/phy/phy_device.c |
| 13 | +++ b/drivers/net/phy/phy_device.c |
| 14 | @@ -1466,6 +1466,9 @@ void phy_detach(struct phy_device *phyde |
| 15 | struct module *ndev_owner = NULL; |
| 16 | struct mii_bus *bus; |
| 17 | |
| 18 | + if (phydev->drv && phydev->drv->detach) |
| 19 | + phydev->drv->detach(phydev); |
| 20 | + |
| 21 | if (phydev->sysfs_links) { |
| 22 | if (dev) |
| 23 | sysfs_remove_link(&dev->dev.kobj, "phydev"); |
| 24 | --- a/include/linux/phy.h |
| 25 | +++ b/include/linux/phy.h |
| 26 | @@ -540,6 +540,12 @@ struct phy_driver { |
| 27 | /* Override default interrupt handling */ |
| 28 | int (*handle_interrupt)(struct phy_device *phydev); |
| 29 | |
| 30 | + /* |
| 31 | + * Called before an ethernet device is detached |
| 32 | + * from the PHY. |
| 33 | + */ |
| 34 | + void (*detach)(struct phy_device *phydev); |
| 35 | + |
| 36 | /* Clears up any memory if needed */ |
| 37 | void (*remove)(struct phy_device *phydev); |
| 38 | |