1c180b225b17c8a246450bfd5e6c71d43dbba51c
[oweals/openwrt.git] / target / linux / generic / pending-5.4 / 703-phy-add-detach-callback-to-struct-phy_driver.patch
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 @@ -1201,6 +1201,9 @@ void phy_detach(struct phy_device *phyde
15         struct module *ndev_owner = dev->dev.parent->driver->owner;
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                 sysfs_remove_link(&dev->dev.kobj, "phydev");
23                 sysfs_remove_link(&phydev->mdio.dev.kobj, "attached_dev");
24 --- a/include/linux/phy.h
25 +++ b/include/linux/phy.h
26 @@ -567,6 +567,12 @@ struct phy_driver {
27          */
28         int (*did_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