All of lore.kernel.org
 help / color / mirror / Atom feed
From: Enguerrand de Ribaucourt  <enguerrand.de-ribaucourt@savoirfairelinux.com>
To: netdev@vger.kernel.org
Cc: pabeni@redhat.com, woojung.huh@microchip.com,
	davem@davemloft.net, UNGLinuxDriver@microchip.com,
	Enguerrand de Ribaucourt 
	<enguerrand.de-ribaucourt@savoirfairelinux.com>
Subject: [PATCH v2] net: lan78xx: prevent LAN88XX specific operations
Date: Tue, 20 Dec 2022 12:37:34 +0100	[thread overview]
Message-ID: <20221220113733.714233-1-enguerrand.de-ribaucourt@savoirfairelinux.com> (raw)
In-Reply-To: <9235D6609DB808459E95D78E17F2E43D408987FF@CHN-SV-EXMX02.mchp-main.com>

Some operations during the cable switch workaround modify the register
LAN88XX_INT_MASK of the PHY. However, this register is specific to the
LAN8835 PHY. For instance, if a DP8322I PHY is connected to the LAN7801,
that register (0x19), corresponds to the LED and MAC address
configuration, resulting in unapropriate behavior.

Use the generic phy interrupt functions instead.

Fixes: 89b36fb5e532 ("lan78xx: Lan7801 Support for Fixed PHY")
Reviewed-by: Paolo Abeni <pabeni@redhat.com>;
Signed-off-by: Enguerrand de Ribaucourt <enguerrand.de-ribaucourt@savoirfairelinux.com>
---
 drivers/net/usb/lan78xx.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index f18ab8e220db..65d5d54994ff 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -28,6 +28,7 @@
 #include <linux/phy_fixed.h>
 #include <linux/of_mdio.h>
 #include <linux/of_net.h>
+#include <linux/phy.h>
 #include "lan78xx.h"
 
 #define DRIVER_AUTHOR	"WOOJUNG HUH <woojung.huh@microchip.com>"
@@ -2123,10 +2124,7 @@ static void lan78xx_link_status_change(struct net_device *net)
 	 * at forced 100 F/H mode.
 	 */
 	if (!phydev->autoneg && (phydev->speed == 100)) {
-		/* disable phy interrupt */
-		temp = phy_read(phydev, LAN88XX_INT_MASK);
-		temp &= ~LAN88XX_INT_MASK_MDINTPIN_EN_;
-		phy_write(phydev, LAN88XX_INT_MASK, temp);
+		phy_disable_interrupts(phydev);
 
 		temp = phy_read(phydev, MII_BMCR);
 		temp &= ~(BMCR_SPEED100 | BMCR_SPEED1000);
@@ -2134,13 +2132,7 @@ static void lan78xx_link_status_change(struct net_device *net)
 		temp |= BMCR_SPEED100;
 		phy_write(phydev, MII_BMCR, temp); /* set to 100 later */
 
-		/* clear pending interrupt generated while workaround */
-		temp = phy_read(phydev, LAN88XX_INT_STS);
-
-		/* enable phy interrupt back */
-		temp = phy_read(phydev, LAN88XX_INT_MASK);
-		temp |= LAN88XX_INT_MASK_MDINTPIN_EN_;
-		phy_write(phydev, LAN88XX_INT_MASK, temp);
+		phy_request_interrupt(phydev);
 	}
 }
 
-- 
2.25.1


  parent reply	other threads:[~2022-12-20 11:38 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-25 22:22 [PATCH 2/2 net] lan78xx: workaround of forced 100 Full/Half duplex mode error Woojung.Huh
2016-04-28 20:36 ` David Miller
2021-01-22 14:19 ` Marc Kleine-Budde
2022-12-16 14:49 ` [PATCH] net: lan78xx: isolate LAN88XX specific operations Enguerrand de Ribaucourt
2022-12-20  9:40   ` Paolo Abeni
2022-12-20 11:37 ` Enguerrand de Ribaucourt [this message]
2022-12-20 12:41   ` [PATCH v2] net: lan78xx: prevent " Paolo Abeni
2022-12-20 12:47     ` Enguerrand de Ribaucourt
2022-12-20 12:45   ` Paolo Abeni
2022-12-20 13:10     ` Enguerrand de Ribaucourt
2022-12-21 16:40   ` kernel test robot
2022-12-20 13:19 ` [PATCH v3 0/3] " Enguerrand de Ribaucourt
2022-12-20 13:19 ` [PATCH v3 1/3] net: phy: add EXPORT_SYMBOL to phy_disable_interrupts() Enguerrand de Ribaucourt
2022-12-20 14:40   ` Heiner Kallweit
2022-12-20 15:02     ` Enguerrand de Ribaucourt
2022-12-20 15:17       ` Andrew Lunn
2022-12-20 15:19       ` Heiner Kallweit
2022-12-20 15:48         ` Enguerrand de Ribaucourt
2022-12-20 16:55           ` Andrew Lunn
2022-12-20 19:43             ` Woojung.Huh
2022-12-21 18:03               ` Yuiko.Oshino
2022-12-20 16:13       ` Russell King (Oracle)
2022-12-20 16:22         ` Enguerrand de Ribaucourt
2022-12-20 16:47           ` AW: " Sven Schuchmann
2022-12-20 13:19 ` [PATCH v3 2/3] net: phy: make phy_enable_interrupts() non-static Enguerrand de Ribaucourt
2022-12-20 13:19 ` [PATCH v3 3/3] net: lan78xx: prevent LAN88XX specific operations Enguerrand de Ribaucourt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221220113733.714233-1-enguerrand.de-ribaucourt@savoirfairelinux.com \
    --to=enguerrand.de-ribaucourt@savoirfairelinux.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=woojung.huh@microchip.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.