lkml.org 
[lkml]   [2021]   [Jul]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] misc: powermate: update the reference count of the usb interface structure
On Sun, Jul 25, 2021 at 12:56:37AM +0100, Salah Triki wrote:
> Hi,
>
> On Sat, Jul 24, 2021 at 04:08:02PM -0700, Dmitry Torokhov wrote:
> >
> > On Sat, Jul 24, 2021 at 10:20:16PM +0100, Salah Triki wrote:
> > > Use usb_get_intf() and usb_put_intf() in order to update the reference
> > > count of the usb interface structure.
> >
> > This is quite pointless as the driver will be unbound from the interface
> > before interface is deleted.
>
> From the documentation of usb_get_intf():
>
> [quote]
>
> Each live reference to a interface must be refcounted.
>
> 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.
>
> [/quote]

I see. In this case I recommend you submit a patch to the documentation
clarifying this, as taking a reference when binding to an interface
makes sense when dealing with a secondary interface, but not primary
one. See for example drivers/usb/class/cdc-acm.c where it binds to the
data interface, but also locates control interface and bumps up
reference to that.

As you may notice there is only a handful of drivers that use this API,
and as I am looking at them most do not actually need to use it.

Thanks.

--
Dmitry

\
 
 \ /
  Last update: 2021-07-25 06:36    [W:0.049 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site