Skip to content

Commit aef05e3

Browse files
jtornosmgregkh
authored andcommitted
net: usb: ax88179_178a: avoid failed operations when device is disconnected
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 from the driver. These operations are not necessary in this situation, so avoid these logs when the device is detached if the result of the operation is -ENODEV and if the new flag informing about the disconnecting status is enabled. cc: <stable@vger.kernel.org> Fixes: e2ca90c ("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> Acked-by: Alan Stern <stern@rowland.harvard.edu> Link: https://lore.kernel.org/r/20231207175007.263907-1-jtornosm@redhat.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent da48708 commit aef05e3

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

drivers/net/usb/ax88179_178a.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ struct ax88179_data {
173173
u8 in_pm;
174174
u32 wol_supported;
175175
u32 wolopts;
176+
u8 disconnecting;
176177
};
177178

178179
struct ax88179_int_data {
@@ -208,6 +209,7 @@ static int __ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
208209
{
209210
int ret;
210211
int (*fn)(struct usbnet *, u8, u8, u16, u16, void *, u16);
212+
struct ax88179_data *ax179_data = dev->driver_priv;
211213

212214
BUG_ON(!dev);
213215

@@ -219,7 +221,7 @@ static int __ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
219221
ret = fn(dev, cmd, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
220222
value, index, data, size);
221223

222-
if (unlikely(ret < 0))
224+
if (unlikely((ret < 0) && !(ret == -ENODEV && ax179_data->disconnecting)))
223225
netdev_warn(dev->net, "Failed to read reg index 0x%04x: %d\n",
224226
index, ret);
225227

@@ -231,6 +233,7 @@ static int __ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
231233
{
232234
int ret;
233235
int (*fn)(struct usbnet *, u8, u8, u16, u16, const void *, u16);
236+
struct ax88179_data *ax179_data = dev->driver_priv;
234237

235238
BUG_ON(!dev);
236239

@@ -242,7 +245,7 @@ static int __ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
242245
ret = fn(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
243246
value, index, data, size);
244247

245-
if (unlikely(ret < 0))
248+
if (unlikely((ret < 0) && !(ret == -ENODEV && ax179_data->disconnecting)))
246249
netdev_warn(dev->net, "Failed to write reg index 0x%04x: %d\n",
247250
index, ret);
248251

@@ -492,6 +495,20 @@ static int ax88179_resume(struct usb_interface *intf)
492495
return usbnet_resume(intf);
493496
}
494497

498+
static void ax88179_disconnect(struct usb_interface *intf)
499+
{
500+
struct usbnet *dev = usb_get_intfdata(intf);
501+
struct ax88179_data *ax179_data;
502+
503+
if (!dev)
504+
return;
505+
506+
ax179_data = dev->driver_priv;
507+
ax179_data->disconnecting = 1;
508+
509+
usbnet_disconnect(intf);
510+
}
511+
495512
static void
496513
ax88179_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
497514
{
@@ -1906,7 +1923,7 @@ static struct usb_driver ax88179_178a_driver = {
19061923
.suspend = ax88179_suspend,
19071924
.resume = ax88179_resume,
19081925
.reset_resume = ax88179_resume,
1909-
.disconnect = usbnet_disconnect,
1926+
.disconnect = ax88179_disconnect,
19101927
.supports_autosuspend = 1,
19111928
.disable_hub_initiated_lpm = 1,
19121929
};

0 commit comments

Comments
 (0)