summaryrefslogtreecommitdiffstats
path: root/drivers/usb/usb-skeleton.c
diff options
context:
space:
mode:
authorOliver Neukum <oliver@neukum.org>2009-09-09 17:08:50 +0200
committerGreg Kroah-Hartman <gregkh@suse.de>2009-09-23 06:46:40 -0700
commit8cd01664344e983d73a85ce604f7c23f475cf303 (patch)
tree6eac7c223c62db18a045cb9b606f59e20b61416a /drivers/usb/usb-skeleton.c
parent798199867385417ba6494472e39c016e3340758c (diff)
downloadlinux-8cd01664344e983d73a85ce604f7c23f475cf303.tar.bz2
USB: O_NONBLOCK in read path of skeleton
Non blocking IO is supported in the read path of usb-skeleton. This is done by just not blocking. As support for handling signals without stopping IO is already there, it can be used for O_NONBLOCK, too. Signed-off-by: Oliver Neukum <oliver@neukum.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/usb-skeleton.c')
-rw-r--r--drivers/usb/usb-skeleton.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
index 768fda9064e9..ef8c877cdd41 100644
--- a/drivers/usb/usb-skeleton.c
+++ b/drivers/usb/usb-skeleton.c
@@ -268,6 +268,11 @@ retry:
spin_unlock_irq(&dev->err_lock);
if (ongoing_io) {
+ /* nonblocking IO shall not wait */
+ if (file->f_flags & O_NONBLOCK) {
+ rv = -EAGAIN;
+ goto exit;
+ }
/*
* IO may take forever
* hence wait in an interruptible state
@@ -351,8 +356,9 @@ retry:
rv = skel_do_read_io(dev, count);
if (rv < 0)
goto exit;
- else
+ else if (!file->f_flags & O_NONBLOCK)
goto retry;
+ rv = -EAGAIN;
}
exit:
mutex_unlock(&dev->io_mutex);