Skip to content

Commit 9b1d5e0

Browse files
Ansueldavem330
authored andcommitted
net: phy: provide whether link has changed in c37_read_status
Some PHY driver might require additional regs call after genphy_c37_read_status() is called. Expand genphy_c37_read_status to provide a bool wheather the link has changed or not to permit PHY driver to skip additional regs call if nothing has changed. Every user of genphy_c37_read_status() is updated with the new additional bool. Signed-off-by: Christian Marangi <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent dd87eaa commit 9b1d5e0

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

drivers/net/phy/broadcom.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,10 +665,11 @@ static int bcm54616s_config_aneg(struct phy_device *phydev)
665665
static int bcm54616s_read_status(struct phy_device *phydev)
666666
{
667667
struct bcm54616s_phy_priv *priv = phydev->priv;
668+
bool changed;
668669
int err;
669670

670671
if (priv->mode_1000bx_en)
671-
err = genphy_c37_read_status(phydev);
672+
err = genphy_c37_read_status(phydev, &changed);
672673
else
673674
err = genphy_read_status(phydev);
674675

drivers/net/phy/phy_device.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2621,12 +2621,15 @@ EXPORT_SYMBOL(genphy_read_status);
26212621
/**
26222622
* genphy_c37_read_status - check the link status and update current link state
26232623
* @phydev: target phy_device struct
2624+
* @changed: pointer where to store if link changed
26242625
*
26252626
* Description: Check the link, then figure out the current state
26262627
* by comparing what we advertise with what the link partner
26272628
* advertises. This function is for Clause 37 1000Base-X mode.
2629+
*
2630+
* If link has changed, @changed is set to true, false otherwise.
26282631
*/
2629-
int genphy_c37_read_status(struct phy_device *phydev)
2632+
int genphy_c37_read_status(struct phy_device *phydev, bool *changed)
26302633
{
26312634
int lpa, err, old_link = phydev->link;
26322635

@@ -2636,9 +2639,13 @@ int genphy_c37_read_status(struct phy_device *phydev)
26362639
return err;
26372640

26382641
/* why bother the PHY if nothing can have changed */
2639-
if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link)
2642+
if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link) {
2643+
*changed = false;
26402644
return 0;
2645+
}
26412646

2647+
/* Signal link has changed */
2648+
*changed = true;
26422649
phydev->duplex = DUPLEX_UNKNOWN;
26432650
phydev->pause = 0;
26442651
phydev->asym_pause = 0;

drivers/net/phy/qcom/at803x.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,9 +912,10 @@ static int at8031_config_intr(struct phy_device *phydev)
912912
static int at8031_read_status(struct phy_device *phydev)
913913
{
914914
struct at803x_priv *priv = phydev->priv;
915+
bool changed;
915916

916917
if (priv->is_1000basex)
917-
return genphy_c37_read_status(phydev);
918+
return genphy_c37_read_status(phydev, &changed);
918919

919920
return at803x_read_status(phydev);
920921
}

include/linux/phy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1876,7 +1876,7 @@ int genphy_write_mmd_unsupported(struct phy_device *phdev, int devnum,
18761876

18771877
/* Clause 37 */
18781878
int genphy_c37_config_aneg(struct phy_device *phydev);
1879-
int genphy_c37_read_status(struct phy_device *phydev);
1879+
int genphy_c37_read_status(struct phy_device *phydev, bool *changed);
18801880

18811881
/* Clause 45 PHY */
18821882
int genphy_c45_restart_aneg(struct phy_device *phydev);

0 commit comments

Comments
 (0)