diff options
Diffstat (limited to 'drivers/net/phy/phy_device.c')
-rw-r--r-- | drivers/net/phy/phy_device.c | 54 |
1 files changed, 37 insertions, 17 deletions
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index b131e555d3c2..ec656d91f14b 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -89,13 +89,23 @@ static bool mdio_bus_phy_may_suspend(struct phy_device *phydev) if (!drv || !phydrv->suspend) return false; - /* PHY not attached? May suspend if the PHY has not already been - * suspended as part of a prior call to phy_disconnect() -> - * phy_detach() -> phy_suspend() because the parent netdev might be the - * MDIO bus driver and clock gated at this point. + /* + * netdev is NULL has three cases: + * - phy is not found + * - phy is found, match to general phy driver + * - phy is found, match to specifical phy driver + * + * Case 1: phy is not found, cannot communicate by MDIO bus. + * Case 2: phy is found: + * if phy dev driver probe/bind err, netdev is not __open__ status, + * mdio bus is unregistered. + * if phy is detached, phy had entered suspended status. + * Case 3: phy is found, phy is detached, phy had entered suspended status. + * + * So, in here, it shouldn't set phy to suspend by calling mdio bus. */ if (!netdev) - return !phydev->suspended; + return false; /* Don't suspend PHY if the attached netdev parent may wakeup. * The parent may point to a PCI device, as in tg3 driver. @@ -252,7 +262,7 @@ static int phy_needs_fixup(struct phy_device *phydev, struct phy_fixup *fixup) } /* Runs any matching fixups for this phydev */ -static int phy_scan_fixups(struct phy_device *phydev) +int phy_scan_fixups(struct phy_device *phydev) { struct phy_fixup *fixup; @@ -272,6 +282,7 @@ static int phy_scan_fixups(struct phy_device *phydev) return 0; } +EXPORT_SYMBOL(phy_scan_fixups); static int phy_bus_match(struct device *dev, struct device_driver *drv) { @@ -1230,15 +1241,7 @@ int genphy_restart_aneg(struct phy_device *phydev) } EXPORT_SYMBOL(genphy_restart_aneg); -/** - * genphy_config_aneg - restart auto-negotiation or write BMCR - * @phydev: target phy_device struct - * - * Description: If auto-negotiation is enabled, we configure the - * advertising, and then restart auto-negotiation. If it is not - * enabled, then we write the BMCR. - */ -int genphy_config_aneg(struct phy_device *phydev) +int genphy_config_aneg_check(struct phy_device *phydev) { int err, changed; @@ -1266,11 +1269,28 @@ int genphy_config_aneg(struct phy_device *phydev) changed = 1; /* do restart aneg */ } + return changed; +} +EXPORT_SYMBOL(genphy_config_aneg_check); + +/** + * genphy_config_aneg - restart auto-negotiation or write BMCR + * @phydev: target phy_device struct + * + * Description: If auto-negotiation is enabled, we configure the + * advertising, and then restart auto-negotiation. If it is not + * enabled, then we write the BMCR. + */ +int genphy_config_aneg(struct phy_device *phydev) +{ + int result; + /* Only restart aneg if we are advertising something different * than we were before. */ - if (changed > 0) - return genphy_restart_aneg(phydev); + result = genphy_config_aneg_check(phydev); + if (result > 0) + result = genphy_restart_aneg(phydev); return 0; } |