On Tue, 21 Sep 2004, Raymond W wrote: > hi > > I couldn't find a developwer faq on www.linux-usb.org, so I thought perhaps this > might be the > right place to ask a few questions. > (I have read lots of the drivers/usb & drivers/usb/host source before asking these > questions. > pegasus, usbnet, usb, usb-uhci, and pwc just to name a few off the top of my head.) > > Please forgive me if this is the wrong place/method. > > In writing a USB device driver I am uncertain as to what the "right thing" to do is > when I receive > an error (urb->status<0) in a usb_complete_t which is reading/receiving data from > the device. > > -ECONNRESET means the urb has been async-unlinked. > -ENOENT means you've been sync-unlinked. > Either way, is it safe to usb_free_urb right then? (Provided the unlinker doesnt > expect to do > the freeing.) > Not asking if usb_free_urb is interrupt safe, but is it safe to free the urb when > these errors > are reported to the usb_complete_t.
Yes. It's safe to call usb_free_urb() at any time, even when the URB is in flight. But after you've called it, don't try to access the URB any more other than in a completion handler. > -EPIPE: > Others: > When other error conditions are identified, what is the appropriate action? It depends on what you want your driver to do. In general, failure with an error is just another form of completion. Whatever action you would take upon completion might well be appropriate whether there's an error or not. > If someone is waiting on data, you should wake them so they know there was an > error? Of course. You wouldn't want to let them sleep until the end of time! > If the urb has an !=0 interval, if I wish to receive more data in the future, do > I need to > usb_clear_halt? usb_unlink_urb & usb_submit_urb ? When your completion handler runs, the URB has been unlinked. (That's true in 2.6 -- 2.4 has slightly different semantics.) If you want to receive more data, you'll have to call usb_submit_urb() again. > Are there error values which might indicate "temporary failure, please resubmit" ? Yes. ENOMEM clearly falls in that category, as does EAGAIN and a few others. Look in Documentation/usb/error-codes.txt and use your judgement. > Thank you for any pointers to dev-specific FAQ or answers to these questions, and > for your time. > > ray Alan Stern ------------------------------------------------------- This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
