]> Gentwo Git Trees - linux/.git/commit
can: esd_usb: Avoid errors triggered from USB disconnect
authorStefan Mätje <stefan.maetje@esd.eu>
Thu, 21 Aug 2025 14:34:22 +0000 (16:34 +0200)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Fri, 19 Sep 2025 18:03:47 +0000 (20:03 +0200)
commit37dc3ea4d2a21f3b0c474ae3aeebcfada6a29655
tree94fee55dd226425857ae85217b6a9345eb456b29
parentc6e07521431ce6d45a0ea2d220df456a7785087c
can: esd_usb: Avoid errors triggered from USB disconnect

The USB stack calls during disconnect the esd_usb_disconnect() callback.
esd_usb_disconnect() calls netdev_unregister() for each network which
in turn calls the net_device_ops::ndo_stop callback esd_usb_close() if
the net device is up.

The esd_usb_close() callback tries to disable all CAN Ids and to reset
the CAN controller of the device sending appropriate control messages.

Sending these messages in .disconnect() is moot and always fails because
either the device is gone or the USB communication is already torn down
by the USB stack in the course of a rmmod operation.

Move the code that sends these control messages to a new function
esd_usb_stop() which is approximately the counterpart of
esd_usb_start() to make code structure less convoluted.

Then change esd_usb_close() not to send the control messages at all if
the ndo_stop() callback is executed from the USB .disconnect()
callback. Add a new flag in_usb_disconnect to the struct esd_usb
device structure to mark this condition which is checked by
esd_usb_close() whether to skip the send operations in esd_usb_start().

Signed-off-by: Stefan Mätje <stefan.maetje@esd.eu>
Link: https://patch.msgid.link/20250821143422.3567029-6-stefan.maetje@esd.eu
[mkl: minor change patch description to imperative language]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/usb/esd_usb.c