USB: core: Update kerneldoc for usb_get_dev() and usb_get_intf()

Bugzilla: http://bugzilla.redhat.com/2084667
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=46653455
Tested: HP ZBook 15 G5/80D5 Laptop

commit f6a9a2d64dd168b7d71076c0e6b2be7db7cb7399
Author: Alan Stern <stern@rowland.harvard.edu>
Date:   Fri Feb 25 09:38:25 2022 -0500

    USB: core: Update kerneldoc for usb_get_dev() and usb_get_intf()

    The kerneldoc for usb_get_dev() and usb_get_intf() says that drivers
    should always refcount the references they hold for the usb_device or
    usb_interface structure, respectively.  But this is an overstatement:
    In many cases drivers do not access these references after they have
    been unbound, and in such cases refcounting is unnecessary.

    This patch updates the kerneldoc for the two routines, explaining when
    a driver does not need to increment and decrement the refcount.  This
    should help dispel misconceptions which might otherwise afflict
    programmers new to the USB subsystem.

    Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
    Link: https://lore.kernel.org/r/Yhjp4Rp9Alipmwtq@rowland.harvard.edu
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Torez Smith <torez@redhat.com>
This commit is contained in:
Torez Smith 2022-07-25 11:48:05 -04:00
parent 22e490aef0
commit 8d29582235
1 changed files with 8 additions and 0 deletions

View File

@ -688,6 +688,10 @@ EXPORT_SYMBOL_GPL(usb_alloc_dev);
* Drivers for USB interfaces should normally record such references in
* their probe() methods, when they bind to an interface, and release
* them by calling usb_put_dev(), in their disconnect() methods.
* However, if a driver does not access the usb_device structure after
* its disconnect() method returns then refcounting is not necessary,
* because the USB core guarantees that a usb_device will not be
* deallocated until after all of its interface drivers have been unbound.
*
* Return: A pointer to the device with the incremented reference counter.
*/
@ -722,6 +726,10 @@ EXPORT_SYMBOL_GPL(usb_put_dev);
* Drivers for USB interfaces should normally record such references in
* their probe() methods, when they bind to an interface, and release
* them by calling usb_put_intf(), in their disconnect() methods.
* However, if a driver does not access the usb_interface structure after
* its disconnect() method returns then refcounting is not necessary,
* because the USB core guarantees that a usb_interface will not be
* deallocated until after its driver has been unbound.
*
* Return: A pointer to the interface with the incremented reference counter.
*/