aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/usb-skeleton.c
diff options
context:
space:
mode:
authorChen Wang <unicornxx.wang@gmail.com>2013-07-18 22:15:18 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-25 15:01:13 -0400
commit140983c283b302167b387646218a97f112cc0c03 (patch)
treeb81f33befcac76ba7e7034e769bf3ce17afa76cc /drivers/usb/usb-skeleton.c
parente6c7efdcb76f11b04e3d3f71c8d764ab75c9423b (diff)
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: Chen Wang <unicornxx.wang@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/usb-skeleton.c')
-rw-r--r--drivers/usb/usb-skeleton.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
index 7ed3b039dbe8..ff97652343a3 100644
--- a/drivers/usb/usb-skeleton.c
+++ b/drivers/usb/usb-skeleton.c
@@ -325,9 +325,8 @@ retry:
325 rv = skel_do_read_io(dev, count); 325 rv = skel_do_read_io(dev, count);
326 if (rv < 0) 326 if (rv < 0)
327 goto exit; 327 goto exit;
328 else if (!(file->f_flags & O_NONBLOCK)) 328 else
329 goto retry; 329 goto retry;
330 rv = -EAGAIN;
331 } 330 }
332exit: 331exit:
333 mutex_unlock(&dev->io_mutex); 332 mutex_unlock(&dev->io_mutex);