From: Chen Wang Date: Fri, 19 Jul 2013 02:15:18 +0000 (+0800) Subject: USB: usb-skeleton.c: add retry for nonblocking read X-Git-Tag: v3.12-rc1~186^2~142 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=140983c283b302167b387646218a97f112cc0c03;p=profile%2Fivi%2Fkernel-x86-ivi.git 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c index 7ed3b03..ff97652 100644 --- a/drivers/usb/usb-skeleton.c +++ b/drivers/usb/usb-skeleton.c @@ -325,9 +325,8 @@ retry: 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);