This skips waiting for a read if O_NONBLOCK is set. Signed-off-by: Oliver Neukum <oneukum@xxxxxxxx> --- drivers/usb/misc/chaoskey.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/usb/misc/chaoskey.c b/drivers/usb/misc/chaoskey.c index d47c2cc65269..0d80cba162a4 100644 --- a/drivers/usb/misc/chaoskey.c +++ b/drivers/usb/misc/chaoskey.c @@ -467,10 +467,14 @@ static ssize_t chaoskey_read(struct file *file, mutex_unlock(&dev->lock); goto bail; } - result = chaoskey_wait_fill(dev); - if (result < 0) { - mutex_unlock(&dev->lock); - goto bail; + if (!(file->f_flags & O_NONBLOCK)) { + result = chaoskey_wait_fill(dev); + if (result < 0) { + mutex_unlock(&dev->lock); + goto bail; + } + } else { + result = -EAGAIN; } } -- 2.16.4