netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: usb: ax88179_178a: avoid failed operations when device is disconnected
@ 2023-11-29 15:16 Jose Ignacio Tornos Martinez
  2023-11-29 15:33 ` Oliver Neukum
  0 siblings, 1 reply; 24+ messages in thread
From: Jose Ignacio Tornos Martinez @ 2023-11-29 15:16 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, linux-usb, netdev, linux-kernel; +Cc: jtornosm

When the device is disconnected we get the following messages showing
failed operations:
Nov 28 20:22:11 localhost kernel: usb 2-3: USB disconnect, device number 2
Nov 28 20:22:11 localhost kernel: ax88179_178a 2-3:1.0 enp2s0u3: unregister 'ax88179_178a' usb-0000:02:00.0-3, ASIX AX88179 USB 3.0 Gigabit Ethernet
Nov 28 20:22:11 localhost kernel: ax88179_178a 2-3:1.0 enp2s0u3: Failed to read reg index 0x0002: -19
Nov 28 20:22:11 localhost kernel: ax88179_178a 2-3:1.0 enp2s0u3: Failed to write reg index 0x0002: -19
Nov 28 20:22:11 localhost kernel: ax88179_178a 2-3:1.0 enp2s0u3 (unregistered): Failed to write reg index 0x0002: -19
Nov 28 20:22:11 localhost kernel: ax88179_178a 2-3:1.0 enp2s0u3 (unregistered): Failed to write reg index 0x0001: -19
Nov 28 20:22:11 localhost kernel: ax88179_178a 2-3:1.0 enp2s0u3 (unregistered): Failed to write reg index 0x0002: -19

The reason is that although the device is detached, normal stop and
unbind operations are commanded. Avoid these unnecessary operations
when the device is detached (state is USB_STATE_NOTATTACHED) so as
not to get the error messages.

Fixes: e2ca90c276e1f ("ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver")
Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
---
 drivers/net/usb/ax88179_178a.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 4ea0e155bb0d..e78d555dd95e 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -1308,16 +1308,18 @@ static void ax88179_unbind(struct usbnet *dev, struct usb_interface *intf)
 	struct ax88179_data *ax179_data = dev->driver_priv;
 	u16 tmp16;
 
-	/* Configure RX control register => stop operation */
-	tmp16 = AX_RX_CTL_STOP;
-	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &tmp16);
+	if (dev->udev->state != USB_STATE_NOTATTACHED) {
+		/* Configure RX control register => stop operation */
+		tmp16 = AX_RX_CTL_STOP;
+		ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &tmp16);
 
-	tmp16 = 0;
-	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp16);
+		tmp16 = 0;
+		ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp16);
 
-	/* Power down ethernet PHY */
-	tmp16 = 0;
-	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, &tmp16);
+		/* Power down ethernet PHY */
+		tmp16 = 0;
+		ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, &tmp16);
+	}
 
 	kfree(ax179_data);
 }
@@ -1663,11 +1665,13 @@ static int ax88179_stop(struct usbnet *dev)
 {
 	u16 tmp16;
 
-	ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
+	if (dev->udev->state != USB_STATE_NOTATTACHED) {
+		ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
 			 2, 2, &tmp16);
-	tmp16 &= ~AX_MEDIUM_RECEIVE_EN;
-	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
+		tmp16 &= ~AX_MEDIUM_RECEIVE_EN;
+		ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE,
 			  2, 2, &tmp16);
+	}
 
 	return 0;
 }
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2023-12-08  5:02 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-29 15:16 [PATCH] net: usb: ax88179_178a: avoid failed operations when device is disconnected Jose Ignacio Tornos Martinez
2023-11-29 15:33 ` Oliver Neukum
2023-11-29 15:40   ` Alan Stern
2023-11-30  8:41     ` Jose Ignacio Tornos Martinez
2023-11-30 15:50       ` Alan Stern
2023-11-30 17:25         ` Jose Ignacio Tornos Martinez
2023-11-30 18:13           ` Alan Stern
2023-12-01 10:46             ` Jose Ignacio Tornos Martinez
2023-12-01 11:51             ` [PATCH v2] " Jose Ignacio Tornos Martinez
2023-12-01 12:25               ` Greg KH
2023-12-01 13:26                 ` [PATCH v3] " Jose Ignacio Tornos Martinez
2023-12-01 16:13                   ` Alan Stern
2023-12-01 17:27                     ` Jose Ignacio Tornos Martinez
2023-12-01 20:14                   ` Oliver Neukum
2023-12-04 11:31                     ` Jose Ignacio Tornos Martinez
2023-12-05 13:51                     ` [PATCH v4] " Jose Ignacio Tornos Martinez
2023-12-05 18:07                       ` Alan Stern
2023-12-06 12:17                         ` Jose Ignacio Tornos Martinez
2023-12-07 11:42                         ` [PATCH v5] " Jose Ignacio Tornos Martinez
2023-12-07 16:41                           ` Alan Stern
2023-12-07 17:50                             ` [PATCH v6] " Jose Ignacio Tornos Martinez
2023-12-07 20:23                               ` Alan Stern
2023-12-07 20:32                                 ` Jakub Kicinski
2023-12-08  4:56                                   ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).