]> www.infradead.org Git - users/hch/misc.git/commitdiff
net: phy: provide whether link has changed in c37_read_status
authorChristian Marangi <ansuelsmth@gmail.com>
Tue, 6 Feb 2024 17:31:09 +0000 (18:31 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sat, 10 Feb 2024 15:36:19 +0000 (15:36 +0000)
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 <ansuelsmth@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/broadcom.c
drivers/net/phy/phy_device.c
drivers/net/phy/qcom/at803x.c
include/linux/phy.h

index 312a8bb35d780e93510959e35584e7bd4fcb4a30..370e4ed450982c6bbbf5c9f6a31fb09c47b63bc9 100644 (file)
@@ -665,10 +665,11 @@ static int bcm54616s_config_aneg(struct phy_device *phydev)
 static int bcm54616s_read_status(struct phy_device *phydev)
 {
        struct bcm54616s_phy_priv *priv = phydev->priv;
+       bool changed;
        int err;
 
        if (priv->mode_1000bx_en)
-               err = genphy_c37_read_status(phydev);
+               err = genphy_c37_read_status(phydev, &changed);
        else
                err = genphy_read_status(phydev);
 
index 71d48152e8d52162ea858840b4e55cb322034eb6..9f37c0bfbf8d1ee1ddbba4041749f102df0d34e7 100644 (file)
@@ -2621,12 +2621,15 @@ EXPORT_SYMBOL(genphy_read_status);
 /**
  * genphy_c37_read_status - check the link status and update current link state
  * @phydev: target phy_device struct
+ * @changed: pointer where to store if link changed
  *
  * Description: Check the link, then figure out the current state
  *   by comparing what we advertise with what the link partner
  *   advertises. This function is for Clause 37 1000Base-X mode.
+ *
+ *   If link has changed, @changed is set to true, false otherwise.
  */
-int genphy_c37_read_status(struct phy_device *phydev)
+int genphy_c37_read_status(struct phy_device *phydev, bool *changed)
 {
        int lpa, err, old_link = phydev->link;
 
@@ -2636,9 +2639,13 @@ int genphy_c37_read_status(struct phy_device *phydev)
                return err;
 
        /* why bother the PHY if nothing can have changed */
-       if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link)
+       if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link) {
+               *changed = false;
                return 0;
+       }
 
+       /* Signal link has changed */
+       *changed = true;
        phydev->duplex = DUPLEX_UNKNOWN;
        phydev->pause = 0;
        phydev->asym_pause = 0;
index 3e3ee4c1d4bc6ba8befcad79feceab84feaaa04b..4717c59d51d042c205218ed32c779a836a86577b 100644 (file)
@@ -912,9 +912,10 @@ static int at8031_config_intr(struct phy_device *phydev)
 static int at8031_read_status(struct phy_device *phydev)
 {
        struct at803x_priv *priv = phydev->priv;
+       bool changed;
 
        if (priv->is_1000basex)
-               return genphy_c37_read_status(phydev);
+               return genphy_c37_read_status(phydev, &changed);
 
        return at803x_read_status(phydev);
 }
index cbd49418b8197433c90c3c2fa6413bdb165cffcb..2249cdb5957a84148df6fa4e9ea3d8afa382b1b2 100644 (file)
@@ -1876,7 +1876,7 @@ int genphy_write_mmd_unsupported(struct phy_device *phdev, int devnum,
 
 /* Clause 37 */
 int genphy_c37_config_aneg(struct phy_device *phydev);
-int genphy_c37_read_status(struct phy_device *phydev);
+int genphy_c37_read_status(struct phy_device *phydev, bool *changed);
 
 /* Clause 45 PHY */
 int genphy_c45_restart_aneg(struct phy_device *phydev);