diff options
author | Oliver Neukum <oliver@neukum.org> | 2009-09-09 17:08:50 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-09-23 06:46:40 -0700 |
commit | 8cd01664344e983d73a85ce604f7c23f475cf303 (patch) | |
tree | 6eac7c223c62db18a045cb9b606f59e20b61416a /drivers/usb/usb-skeleton.c | |
parent | 798199867385417ba6494472e39c016e3340758c (diff) |
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.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c index 768fda9064e..ef8c877cdd4 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); |