1 From 9b1d5e055508393561e26bd1720f4c2639b03b1a Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Tue, 6 Feb 2024 18:31:09 +0100
4 Subject: [PATCH 06/10] net: phy: provide whether link has changed in
7 Some PHY driver might require additional regs call after
8 genphy_c37_read_status() is called.
10 Expand genphy_c37_read_status to provide a bool wheather the link has
11 changed or not to permit PHY driver to skip additional regs call if
14 Every user of genphy_c37_read_status() is updated with the new
17 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
18 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
19 Signed-off-by: David S. Miller <davem@davemloft.net>
21 drivers/net/phy/broadcom.c | 3 ++-
22 drivers/net/phy/phy_device.c | 11 +++++++++--
23 drivers/net/phy/qcom/at803x.c | 3 ++-
24 include/linux/phy.h | 2 +-
25 4 files changed, 14 insertions(+), 5 deletions(-)
27 --- a/drivers/net/phy/broadcom.c
28 +++ b/drivers/net/phy/broadcom.c
29 @@ -665,10 +665,11 @@ static int bcm54616s_config_aneg(struct
30 static int bcm54616s_read_status(struct phy_device *phydev)
32 struct bcm54616s_phy_priv *priv = phydev->priv;
36 if (priv->mode_1000bx_en)
37 - err = genphy_c37_read_status(phydev);
38 + err = genphy_c37_read_status(phydev, &changed);
40 err = genphy_read_status(phydev);
42 --- a/drivers/net/phy/phy_device.c
43 +++ b/drivers/net/phy/phy_device.c
44 @@ -2615,12 +2615,15 @@ EXPORT_SYMBOL(genphy_read_status);
46 * genphy_c37_read_status - check the link status and update current link state
47 * @phydev: target phy_device struct
48 + * @changed: pointer where to store if link changed
50 * Description: Check the link, then figure out the current state
51 * by comparing what we advertise with what the link partner
52 * advertises. This function is for Clause 37 1000Base-X mode.
54 + * If link has changed, @changed is set to true, false otherwise.
56 -int genphy_c37_read_status(struct phy_device *phydev)
57 +int genphy_c37_read_status(struct phy_device *phydev, bool *changed)
59 int lpa, err, old_link = phydev->link;
61 @@ -2630,9 +2633,13 @@ int genphy_c37_read_status(struct phy_de
64 /* why bother the PHY if nothing can have changed */
65 - if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link)
66 + if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link) {
71 + /* Signal link has changed */
73 phydev->duplex = DUPLEX_UNKNOWN;
75 phydev->asym_pause = 0;
76 --- a/drivers/net/phy/qcom/at803x.c
77 +++ b/drivers/net/phy/qcom/at803x.c
78 @@ -912,9 +912,10 @@ static int at8031_config_intr(struct phy
79 static int at8031_read_status(struct phy_device *phydev)
81 struct at803x_priv *priv = phydev->priv;
84 if (priv->is_1000basex)
85 - return genphy_c37_read_status(phydev);
86 + return genphy_c37_read_status(phydev, &changed);
88 return at803x_read_status(phydev);
90 --- a/include/linux/phy.h
91 +++ b/include/linux/phy.h
92 @@ -1849,7 +1849,7 @@ int genphy_write_mmd_unsupported(struct
95 int genphy_c37_config_aneg(struct phy_device *phydev);
96 -int genphy_c37_read_status(struct phy_device *phydev);
97 +int genphy_c37_read_status(struct phy_device *phydev, bool *changed);
100 int genphy_c45_restart_aneg(struct phy_device *phydev);