Re: [PATCH 04/11] remove usb_interface pointer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 7 Jun 2012, Stefani Seibold wrote:

> Am Donnerstag, den 07.06.2012, 10:28 -0400 schrieb Alan Stern:
> > On Thu, 7 Jun 2012, Stefani Seibold wrote:
> > 
> > > I tried to implement your idea to kick away the usb_device pointer, but
> > > i think it is impossible. The skel_delete() function needs the
> > > usb_device pointer for calling usb_put, which is called from
> > > skel_disconnect() or skel_release().
> >   
> > Does skel_delete() really need to call usb_put_dev()?  I suspect that  
> > the driver doesn't need to take a reference to either the device or the
> > interface.
> >  
> 
> I think it will be needed, since usb core will decrement the reference
> when the device go away.

But before it decrements the reference, it will unbind the driver.  As 
long as usb-skeleton is careful not to access the device or the 
interface after the disconnect routine returns, it doesn't need to keep 
a reference.

>  Lock every access to the usb core if a tedious
> thing and will waste a lot of code.

With proper design, it's not necessary to lock every access.

> The problem with hotpluging is not the plug, it is the unplug, which can
> happen any time.
> 
> BTW: An interface have no reference count.

Sure it does.  Look at the definitions of usb_get_intf() and 
usb_put_intf() in drivers/usb/core/usb.c.

> > If skel_delete is changed then we don't need the usb_device pointer.
> > 
> 
> I have no idea how to do this. Every USB driver i know stores the
> usb_device pointer.
> 
> Maybe you have an idea?

No, I was wrong.  It turns out we really do need to keep the udev 
pointer, because it gets used in calls to usb_fill_bulk_urb().  However 
there's nothing wrong with keeping pointers to both the device and the 
interface, if there's a good reason for doing so.

(It also gets used in calls to usb_alloc_coherent(), but I would prefer
to get rid of the coherent buffers.  They are rarely useful and don't
belong here.)

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux