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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
7981998673
commit
8cd0166434
@@ -268,6 +268,11 @@ retry:
|
|||||||
spin_unlock_irq(&dev->err_lock);
|
spin_unlock_irq(&dev->err_lock);
|
||||||
|
|
||||||
if (ongoing_io) {
|
if (ongoing_io) {
|
||||||
|
/* nonblocking IO shall not wait */
|
||||||
|
if (file->f_flags & O_NONBLOCK) {
|
||||||
|
rv = -EAGAIN;
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* IO may take forever
|
* IO may take forever
|
||||||
* hence wait in an interruptible state
|
* hence wait in an interruptible state
|
||||||
@@ -351,8 +356,9 @@ retry:
|
|||||||
rv = skel_do_read_io(dev, count);
|
rv = skel_do_read_io(dev, count);
|
||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
goto exit;
|
goto exit;
|
||||||
else
|
else if (!file->f_flags & O_NONBLOCK)
|
||||||
goto retry;
|
goto retry;
|
||||||
|
rv = -EAGAIN;
|
||||||
}
|
}
|
||||||
exit:
|
exit:
|
||||||
mutex_unlock(&dev->io_mutex);
|
mutex_unlock(&dev->io_mutex);
|
||||||
|
Reference in New Issue
Block a user