Message ID | 20200921113732.11524-4-oneukum@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [RFT,1/4] chaoskey: O_NONBLOCK in concurrent reads | expand |
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; } }
This skips waiting for a read if O_NONBLOCK is set. Signed-off-by: Oliver Neukum <oneukum@suse.com> --- drivers/usb/misc/chaoskey.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)