2012-11-19 03:02:01

by Harvey Yang

[permalink] [raw]
Subject: [RFC] usb: add 'usb_get_intf()' call into the probe methods of drivers for usb interfaces.

Hi, all
I checked many usb drivers in the mainline kernel which do not record
this reference in their probe methods. But according to the documents
about this function, we shoud record this reference in our probe
methods, just as the call to 'usb_get_dev()' to reference a usb
device. Are these usb drivers right or we need to fix them?


2012-11-20 16:09:40

by Alan Stern

[permalink] [raw]
Subject: Re: [RFC] usb: add 'usb_get_intf()' call into the probe methods of drivers for usb interfaces.

On Mon, 19 Nov 2012, harvey yang wrote:

> Hi, all
> I checked many usb drivers in the mainline kernel which do not record
> this reference in their probe methods. But according to the documents
> about this function, we shoud record this reference in our probe
> methods, just as the call to 'usb_get_dev()' to reference a usb
> device. Are these usb drivers right or we need to fix them?

The drivers are right; they do not need to be fixed. The reason is
because the drivers will be unbound automatically when the device or
interface is unregistered.

The only reason for a driver to take a reference would be if it wanted
to continue using the device after it was unbound. But drivers aren't
supposed to do that.

Alan Stern

2012-11-21 01:51:26

by Harvey Yang

[permalink] [raw]
Subject: Re: [RFC] usb: add 'usb_get_intf()' call into the probe methods of drivers for usb interfaces.

Thanks for your comments :)

Harvey


On Wed, Nov 21, 2012 at 12:09 AM, Alan Stern <[email protected]> wrote:
> On Mon, 19 Nov 2012, harvey yang wrote:
>
>> Hi, all
>> I checked many usb drivers in the mainline kernel which do not record
>> this reference in their probe methods. But according to the documents
>> about this function, we shoud record this reference in our probe
>> methods, just as the call to 'usb_get_dev()' to reference a usb
>> device. Are these usb drivers right or we need to fix them?
>
> The drivers are right; they do not need to be fixed. The reason is
> because the drivers will be unbound automatically when the device or
> interface is unregistered.
>
> The only reason for a driver to take a reference would be if it wanted
> to continue using the device after it was unbound. But drivers aren't
> supposed to do that.
>
> Alan Stern
>