1 From d42c6bf2752a46bdf3931bd6e56db419742fbb20 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Mon, 17 Feb 2020 23:55:22 +0100
4 Subject: [PATCH 3/3] ag71xx: Run ag71xx_link_adjust() only when needed
6 My system printed this line every second:
7 ag71xx 19000000.eth eth0: Link is Up - 1Gbps/Full - flow control off
8 The function ag71xx_phy_link_adjust() was called by the PHY layer every
9 second even when nothing changed.
11 With this patch the old status is stored and the real
12 ag71xx_link_adjust() function is only called when when something really
13 changed. This way the update and also this print is only done once any
16 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
17 Fixes: d51b6ce441d3 ("net: ethernet: add ag71xx driver")
19 drivers/net/ethernet/atheros/ag71xx.c | 24 +++++++++++++++++++++++-
20 1 file changed, 23 insertions(+), 1 deletion(-)
22 --- a/drivers/net/ethernet/atheros/ag71xx.c
23 +++ b/drivers/net/ethernet/atheros/ag71xx.c
24 @@ -307,6 +307,10 @@ struct ag71xx {
26 const struct ag71xx_dcfg *dcfg;
32 /* From this point onwards we're not looking at per-packet fields. */
33 void __iomem *mac_base;
35 @@ -854,6 +858,7 @@ static void ag71xx_link_adjust(struct ag
37 if (!phydev->link && update) {
39 + phy_print_status(phydev);
43 @@ -907,8 +912,25 @@ static void ag71xx_link_adjust(struct ag
44 static void ag71xx_phy_link_adjust(struct net_device *ndev)
46 struct ag71xx *ag = netdev_priv(ndev);
47 + struct phy_device *phydev = ndev->phydev;
48 + int status_change = 0;
51 + if (ag->duplex != phydev->duplex
52 + || ag->speed != phydev->speed) {
57 + if (phydev->link != ag->link)
60 + ag->link = phydev->link;
61 + ag->duplex = phydev->duplex;
62 + ag->speed = phydev->speed;
64 - ag71xx_link_adjust(ag, true);
66 + ag71xx_link_adjust(ag, true);
69 static int ag71xx_phy_connect(struct ag71xx *ag)