On Tue, 23 May 2006, Franck Bui-Huu wrote:

> ok so the code can be rewritten as following:
> 
>        clear_bit(US_FLIDX_URB_ACTIVE, &us->flags);
>        if (timeout <= 0) {
>                US_DEBUGP("%s -- cancelling URB\n", !timeout ?
> "Timeout" : "Signal");
>                usb_unlink_urb(us->current_urb);
>        }

Yes, except for the unlikely (but not impossible) case where the URB 
gets aborted and unlinked just as the timeout expires.  Then you would try 
to unlink it a second time, which wouldn't hurt anything.

> > Come to think of it, the code always needs to wait until the URB has
> > completed.  So after you call usb_unlink_urb, you need another
> > wait_for_completion -- non-interruptible and with no timeout.
> 
> It seems to be needed for _all_ drivers. A generic service provided by the 
> core
> which unlinks an urb _and_ waits for its completion...maybe we should start a
> new thread for that...

There already is such a service.  It's called usb_kill_urb.  It has 
slightly higher overhead than usb_unlink_urb + wait_for_completion, but 
since this is a low-probability error pathway that doesn't matter.

Alan Stern



-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to