On Tue, 23 Jan 2007, Guenther Sohler wrote: > Dear Group, > > Some time before I have already asked about a review of my driver. > In the meantime, I have done some rework and no semaphore in interrupt > context anymore :) > > My driver reads data from a USB device and offers them to a device file. > > However I do not yet know, how to handle situations when the user requests > data, but the driver cannot deliver. > If i return -EAGAIN in the read functions, 'cat' says that the resource is > temporarily unavailable. > I i just run "schedule" to do something else in the meantime, the system > actually waits for new data, but nothing can interrupt the thing(no CTRL C, > no kill -9 , nothing!) > > My intent is to do an interruptible blocking in this case. How would i > implement this properly ?
You should check whether the device file was opened with O_NONBLOCK. If it was then returning -EAGAIN is the correct thing to do. Otherwise you should use wait_for_completion_interruptible(). When the function call returns, check for a pending signal before continuing. There are examples in Linux Device Drivers, 3rd ed. Alan Stern ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel