On Mon, Apr 08, 2002 at 03:12:26PM -0700, David Brownell wrote:
> > But why have a special case for hub/hcd use that is different from the
> > drivers?  If a driver wants to grab a device, it should be able to use
> > it until it decrements the count.  
> 
> Yes, but drivers are also required to stop using the device completely
> when they return from disconnect() processing for its interface.  At
> that point they've stopped using it, and decremented the refcount
> so that their contribution is zero, but the count itself is nonzero ...
> just like before probe().
> 
> Drivers are never the first to increment a count, or last to decrement.
> (Unless they've got significant bugs...)

Today this is a requirement for drivers, but only because of the way the
current code works.

For only one simple example of why it might be nice for drivers to be
able to drop the last reference to a usb device, take a look at the
visor driver.  close() ends up getting called right after disconnect()
happens for a wide range of devices.  We go through some pretty good
race condition handling to properly deal with this.  If a usb device
could be "used" even if the device is not present, drivers have a much
easier time of things.  Which is a good thing :)

Just like the change to struct urb to add reference counting, it's not
necessarily a requirement, or a fix for a bug, but it enables simpler
logic, and less places race conditions or other kinds of errors can
happen.

Also, if we have this, the logic to handle when a device is
disconnected, and the driver wants to keep the userspace handle open,
dropping data on the floor, until the device is reconnected, is much
easier.  I've heard talk that the network people want this for their USB
devices, and I know there are usb-serial customers who almost demand
this functionality.

I've applied this patch, and will work on this idea later.

thanks,

greg k-h

_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Sponsored by http://www.ThinkGeek.com/

Reply via email to