From: Oliver Neukum Date: Wed, 9 Sep 2009 15:08:50 +0000 (+0200) Subject: USB: O_NONBLOCK in read path of skeleton X-Git-Tag: firefly_0821_release~12454^2~2 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8cd01664344e983d73a85ce604f7c23f475cf303;p=firefly-linux-kernel-4.4.55.git 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 Signed-off-by: Greg Kroah-Hartman --- 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);