1 From 2c3db705737cf52d7d24c993f0889b25b956c718 Mon Sep 17 00:00:00 2001
2 From: Heiner Kallweit <hkallweit1@gmail.com>
3 Date: Mon, 18 Feb 2019 21:27:18 +0100
4 Subject: [PATCH 605/660] net: phy: add genphy_c45_check_and_restart_aneg
6 This function will be used by config_aneg callback implementations of
7 PHY drivers and allows to reduce boilerplate code.
9 Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
10 Signed-off-by: David S. Miller <davem@davemloft.net>
12 drivers/net/phy/phy-c45.c | 30 ++++++++++++++++++++++++++++++
13 include/linux/phy.h | 1 +
14 2 files changed, 31 insertions(+)
16 --- a/drivers/net/phy/phy-c45.c
17 +++ b/drivers/net/phy/phy-c45.c
18 @@ -110,6 +110,36 @@ int genphy_c45_restart_aneg(struct phy_d
19 EXPORT_SYMBOL_GPL(genphy_c45_restart_aneg);
22 + * genphy_c45_check_and_restart_aneg - Enable and restart auto-negotiation
23 + * @phydev: target phy_device struct
24 + * @restart: whether aneg restart is requested
26 + * This assumes that the auto-negotiation MMD is present.
28 + * Check, and restart auto-negotiation if needed.
30 +int genphy_c45_check_and_restart_aneg(struct phy_device *phydev, bool restart)
35 + /* Configure and restart aneg if it wasn't set before */
36 + ret = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_CTRL1);
40 + if (!(ret & MDIO_AN_CTRL1_ENABLE))
45 + ret = genphy_c45_restart_aneg(phydev);
49 +EXPORT_SYMBOL_GPL(genphy_c45_check_and_restart_aneg);
52 * genphy_c45_aneg_done - return auto-negotiation complete status
53 * @phydev: target phy_device struct
55 --- a/include/linux/phy.h
56 +++ b/include/linux/phy.h
57 @@ -1098,6 +1098,7 @@ int genphy_write_mmd_unsupported(struct
60 int genphy_c45_restart_aneg(struct phy_device *phydev);
61 +int genphy_c45_check_and_restart_aneg(struct phy_device *phydev, bool restart);
62 int genphy_c45_aneg_done(struct phy_device *phydev);
63 int genphy_c45_read_link(struct phy_device *phydev, u32 mmd_mask);
64 int genphy_c45_read_lpa(struct phy_device *phydev);