On Mon, 29 Oct 2007, Phil Endecott wrote: > Dear Experts, > > I have a simple user-space driver that uses usbdevfs. > > As I understand it, there is no way to select() on data being available > on an endpoint. So I have one thread per endpoint which does an > ioctl(USBDEVFS_BULK) read. This is fine, until I need to shut down > (that part of) the driver. Ideally, I would like to be able to > pthread_cancel the threads - but ioctl is not a cancellation point. > Similarly, I could send a signal to the thread, but according to 'man > ioctl', ioctl does not return EINTR to indicate that it has been > interrupted by a signal. > > I've considered the possibility that ioctl(USBDEVFS_BULK) might in fact > return EINTR if it gets a signal; I've tracked the code path as far as > a call to wait_for_completion_timeout() in usb_start_wait_urb(); I > think that that would be wait_for_completion_interruptible_timeout() if > it were interruptible by a signal, yes?
That's right. > So, I'm now looking at using ioctl(USBDEVFS_SUBMITURB) and > ioctl(USBDEVFS_REAPURB) instead. (I think I'll need to use these > anyway eventually, in order to have more than one URB in progress > simultaneously, for improved throughput.) Yes; for anything at all complicated you're better off with asynchronous I/O. > Hopefully I can submit a > request (which should not block) and I'll get a signal when it's ready > - except that usbdevfs.h says "signal to be sent on error" - does it > really not send a signal if the URB completes successfully? The code > in async_completed() seems to send the signal irrespective of the value > in urb->status. The comment in the header file is wrong; the signal always gets sent provided you set signr to something other than 0. > Or maybe there is some other approach that I should be taking. Nope. This is the way to go. Alan Stern ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Linux-usb-users@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-users