usb: musb: gadget: read ep0 fifo only if rxcount is non zero
authorRavi Babu <ravibabu@ti.com>
Tue, 2 Apr 2013 07:52:42 +0000 (13:22 +0530)
committerFelipe Balbi <balbi@ti.com>
Tue, 2 Apr 2013 08:42:50 +0000 (11:42 +0300)
avoid reading fifo rxcount is zero of fifo is empty, hence
read fifo only if rxcount is non-zero

Signed-off-by: Ravi Babu <ravibabu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/musb/musb_gadget_ep0.c

index c9c1ac4e075f758ae01eaf0a79b738ee41da0611..2af45a0c8930b35ca645834c157291198c383aca 100644 (file)
@@ -505,8 +505,10 @@ static void ep0_rxstate(struct musb *musb)
                        req->status = -EOVERFLOW;
                        count = len;
                }
-               musb_read_fifo(&musb->endpoints[0], count, buf);
-               req->actual += count;
+               if (count > 0) {
+                       musb_read_fifo(&musb->endpoints[0], count, buf);
+                       req->actual += count;
+               }
                csr = MUSB_CSR0_P_SVDRXPKTRDY;
                if (count < 64 || req->actual == req->length) {
                        musb->ep0_state = MUSB_EP0_STAGE_STATUSIN;