Prageeth wrote:
hi all,

in my driver i need to provide synchronous read/write
operations to the application. moreover, operation
cancellation is also needed.


-what is the most recommended way to wait for
completion of an urb?

Submit using usb_submit_urb(), then if you don't need operation cancellation, use <linux/completion.h> primitives to wait.

If you need cancelation, <linux/wait.h> primitives
are one option, like:

 - wait_event_interruptible()
 - wait_event_interruptible_timeout()

Yes, there's no wait_event_timeout() without the
option of breaking out on interrupts; sigh.  But
it seems like you don't need that option.


When those primitives complete "early", then call usb_unlink_urb() and then use wait_event() to catch the canceled URB. (Even if you gave up just a smidgeon too early, and it already completed...)

You can use a struct completion with these, and
have the urb completion handler calling complete().

There's another wait/synchronize primitive that
I found at one point, I think the block layer
used it, which involved a bit less inlined code
and didn't necessarily require everything to be
interruptible.  I lost track of it though.




-i was planning to use a modified version of
usb_start_wait_urb() used inside usb_bulk_msg()

is any better methods possible?

Absolutely. That code needs to be replaced, it's not even correct in certain cases.

- Dave




------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to