On Mon, May 17, 2004 at 12:41:42PM -0400, Alan Stern wrote: > +void usb_kill_urb(struct urb *urb) > +{ > + if (!(urb->dev && urb->dev->bus && urb->dev->bus->op)) > + return; > + urb->reject = 1; > + urb->dev->bus->op->unlink_urb(urb, -ENOENT); > + wait_event(usb_kill_urb_queue, atomic_read(&urb->kref.refcount) <= 1); > + urb->reject = 0; > }
Heh, no, you can't just sit and spin on the refcount, because that will not work if I do: usb_free_urb(urb); usb_kill_urb(urb); And that last urb->reject = 0 will oops if I do that :) (and yes, some drivers do that already today with a call to usb_submit_urb() followed by a call to usb_free_urb().) Or what if I do: usb_get_urb(urb); usb_get_urb(urb); usb_get_urb(urb); usb_kill_urb(urb); which will cause this function to deadlock. You need to grab a reference to the urb at the beginning of the call, and decrement it at the end of it. But in the middle there, you can't count on a paticular refcount value, so you will have to trigger off of something else. thanks, greg k-h ------------------------------------------------------- This SF.Net email is sponsored by: SourceForge.net Broadband Sign-up now for SourceForge Broadband and get the fastest 6.0/768 connection for only $19.95/mo for the first 3 months! http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel