aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Neukum <oliver@neukum.org>2009-09-09 11:08:50 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-09-23 09:46:40 -0400
commit8cd01664344e983d73a85ce604f7c23f475cf303 (patch)
tree6eac7c223c62db18a045cb9b606f59e20b61416a
parent798199867385417ba6494472e39c016e3340758c (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>
-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:
268 spin_unlock_irq(&dev->err_lock); 268 spin_unlock_irq(&dev->err_lock);
269 269
270 if (ongoing_io) { 270 if (ongoing_io) {
271 /* nonblocking IO shall not wait */
272 if (file->f_flags & O_NONBLOCK) {
273 rv = -EAGAIN;
274 goto exit;
275 }
271 /* 276 /*
272 * IO may take forever 277 * IO may take forever
273 * hence wait in an interruptible state 278 * hence wait in an interruptible state
@@ -351,8 +356,9 @@ retry:
351 rv = skel_do_read_io(dev, count); 356 rv = skel_do_read_io(dev, count);
352 if (rv < 0) 357 if (rv < 0)
353 goto exit; 358 goto exit;
354 else 359 else if (!file->f_flags & O_NONBLOCK)
355 goto retry; 360 goto retry;
361 rv = -EAGAIN;
356 } 362 }
357exit: 363exit:
358 mutex_unlock(&dev->io_mutex); 364 mutex_unlock(&dev->io_mutex);