Commit 140983c2 authored by Chen Wang's avatar Chen Wang Committed by Greg Kroah-Hartman

USB: usb-skeleton.c: add retry for nonblocking read

Updated skel_read() in usb-skeleton.c. When there is no data in the
buffer, we would allow retry for both blocking and nonblocking cases.
Original logic give retry only for blocking case. Actually we can also
allow retry for nonblocking case. This will reuse the existing retry
logic and handle the return of -EAGAIN in one place. Also if the data to
be read is short and can be retrieved in quick time, we can also give a
chance for nonblocking case and may catch the data and copy it back to
userspace in one read() call too.
Signed-off-by: default avatarChen Wang <unicornxx.wang@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e6c7efdc
......@@ -325,9 +325,8 @@ static ssize_t skel_read(struct file *file, char *buffer, size_t count,
rv = skel_do_read_io(dev, count);
if (rv < 0)
goto exit;
else if (!(file->f_flags & O_NONBLOCK))
else
goto retry;
rv = -EAGAIN;
}
exit:
mutex_unlock(&dev->io_mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment