From beb1f07206810a8758487aa3131a89a97b288c77 Mon Sep 17 00:00:00 2001 From: Russell King Date: Mon, 26 Aug 2019 12:19:35 +0100 Subject: net: phy: provide phy driver start/stop hooks Provide phy driver start/stop hooks so that the PHY driver knows when the network driver is starting or stopping. This will be used for the Marvell 10G driver so that we can sanely refuse to start if the PHYs firmware is not present, and also so that we can sanely support SFPs behind the PHY. Signed-off-by: Russell King --- drivers/net/phy/phy.c | 5 +++++ include/linux/phy.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index beb2b66da132..edfe239af876 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -1051,6 +1051,8 @@ void phy_stop(struct phy_device *phydev) sfp_upstream_stop(phydev->sfp_bus); phydev->state = PHY_HALTED; + if (phydev->drv->stop) + phydev->drv->stop(phydev); mutex_unlock(&phydev->lock); @@ -1084,6 +1086,9 @@ void phy_start(struct phy_device *phydev) goto out; } + if (phydev->drv->start && phydev->drv->start(phydev)) + goto out; + if (phydev->sfp_bus) sfp_upstream_start(phydev->sfp_bus); diff --git a/include/linux/phy.h b/include/linux/phy.h index 460be66800d0..cbdf14a852d8 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -803,6 +803,9 @@ struct phy_driver { /** @resume: Resume the hardware, restoring state if needed */ int (*resume)(struct phy_device *phydev); + int (*start)(struct phy_device *phydev); + void (*stop)(struct phy_device *phydev); + /** * @config_aneg: Configures the advertisement and resets * autonegotiation if phydev->autoneg is on, -- cgit