diff options
author | Heiner Kallweit <hkallweit1@gmail.com> | 2019-02-05 22:41:37 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-02-07 06:46:49 +0300 |
commit | a6e11f6bbd29a92d1357c2f3033a70fb1b767432 (patch) | |
tree | f0a684d83cb537dbfbd6106bf48c1d97339e2dd9 /drivers/net/phy/phy-c45.c | |
parent | 7d8e249f393a1aca30bde876e932401d2c78bc9f (diff) | |
download | linux-a6e11f6bbd29a92d1357c2f3033a70fb1b767432.tar.xz |
net: phy: improve genphy_c45_read_link
Let's make genphy_c45_read_link behave the same as genphy_update_link
and set phydev->link in the function directly. This allows to simplify
the callers. In addition don't check further devices once we detect
that at least one device reports link as down.
v2:
- remove an unused variable
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/phy/phy-c45.c')
-rw-r--r-- | drivers/net/phy/phy-c45.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c index 519866679c91..c92d0fb7ec4f 100644 --- a/drivers/net/phy/phy-c45.c +++ b/drivers/net/phy/phy-c45.c @@ -121,7 +121,7 @@ EXPORT_SYMBOL_GPL(genphy_c45_aneg_done); * @mmd_mask: MMDs to read status from * * Read the link status from the specified MMDs, and if they all indicate - * that the link is up, return positive. If an error is encountered, + * that the link is up, set phydev->link to 1. If an error is encountered, * a negative errno will be returned, otherwise zero. */ int genphy_c45_read_link(struct phy_device *phydev, u32 mmd_mask) @@ -129,7 +129,7 @@ int genphy_c45_read_link(struct phy_device *phydev, u32 mmd_mask) int val, devad; bool link = true; - while (mmd_mask) { + while (mmd_mask && link) { devad = __ffs(mmd_mask); mmd_mask &= ~BIT(devad); @@ -145,7 +145,9 @@ int genphy_c45_read_link(struct phy_device *phydev, u32 mmd_mask) link = false; } - return link; + phydev->link = link; + + return 0; } EXPORT_SYMBOL_GPL(genphy_c45_read_link); @@ -265,7 +267,6 @@ EXPORT_SYMBOL_GPL(gen10g_config_aneg); int gen10g_read_status(struct phy_device *phydev) { u32 mmd_mask = phydev->c45_ids.devices_in_package; - int ret; /* For now just lie and say it's 10G all the time */ phydev->speed = SPEED_10000; @@ -274,11 +275,7 @@ int gen10g_read_status(struct phy_device *phydev) /* Avoid reading the vendor MMDs */ mmd_mask &= ~(BIT(MDIO_MMD_VEND1) | BIT(MDIO_MMD_VEND2)); - ret = genphy_c45_read_link(phydev, mmd_mask); - - phydev->link = ret > 0 ? 1 : 0; - - return 0; + return genphy_c45_read_link(phydev, mmd_mask); } EXPORT_SYMBOL_GPL(gen10g_read_status); |