[lkml]   [2022]   [Dec]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH] USB: drop misleading usb_set_intfdata() kernel doc
The struct device driver-data pointer is used for any data that a driver
may need in various callbacks while bound to the device. For
convenience, subsystems typically provide wrappers such as
usb_set_intfdata() of the generic accessor functions for use in bus

There is generally no longer any need for a driver to clear the pointer,
but since commit 0998d0631001 ("device-core: Ensure drvdata = NULL when
no driver is bound") the driver-data pointer is set to NULL by driver
core post unbind anyway.

For historical reasons, USB core also clears this pointer when an
explicitly claimed interface is released.

Due to a misunderstanding, a redundant and misleading kernel doc comment
for usb_set_intfdata() was recently added which claimed that the driver
data pointer must not be cleared during disconnect before "all actions
[are] completed", which is both imprecise and incorrect.

Specifically, drivers like cdc-acm which claim additional interfaces use
the driver-data pointer as a flag which is cleared when the first
interface is unbound. As long as a driver does not do something odd like
dereference the pointer in, for example, completion callbacks, this can
be done at any time during disconnect. And in any case this is no
different than for any other resource, like the driver data itself,
which may be freed by the disconnect callback.

Drop the incorrect and unnecessary comment.

Fixes: 27ef17849779 ("usb: add usb_set_intfdata() documentation")
Signed-off-by: Johan Hovold <>
include/linux/usb.h | 12 ------------
1 file changed, 12 deletions(-)

diff --git a/include/linux/usb.h b/include/linux/usb.h
index b47371d44d1b..010c681b8822 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -266,18 +266,6 @@ static inline void *usb_get_intfdata(struct usb_interface *intf)
return dev_get_drvdata(&intf->dev);

- * usb_set_intfdata() - associate driver-specific data with the interface
- * @intf: the usb interface
- * @data: pointer to the device priv structure or %NULL
- *
- * Drivers should use this function in their probe() to associate their
- * driver-specific data with the usb interface.
- *
- * When disconnecting, the core will take care of setting @intf back to %NULL,
- * so no actions are needed on the driver side. The interface should not be set
- * to %NULL before all actions completed (e.g. no outsanding URB remaining).
- */
static inline void usb_set_intfdata(struct usb_interface *intf, void *data)
dev_set_drvdata(&intf->dev, data);
 \ /
  Last update: 2022-12-11 13:08    [W:0.257 / U:0.560 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site