aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Wu <cooloney@kernel.org>2008-09-11 04:53:22 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-10-17 17:40:59 -0400
commit64ca44a65adf131c4df5124fe0fcdc3896f0f0dc (patch)
tree328ab041e72f51ec83d7a0f01391ecb4e08ac7a2
parent2492e6747f2441562b1341cef1d46e076f346a1f (diff)
usb: musb: do not mess up count number and CSR0 register value
Signed-off-by: Bryan Wu <cooloney@kernel.org> Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/usb/musb/musb_gadget_ep0.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/usb/musb/musb_gadget_ep0.c b/drivers/usb/musb/musb_gadget_ep0.c
index a57652fff39c..3f5e30ddfa27 100644
--- a/drivers/usb/musb/musb_gadget_ep0.c
+++ b/drivers/usb/musb/musb_gadget_ep0.c
@@ -437,7 +437,7 @@ static void ep0_rxstate(struct musb *musb)
437{ 437{
438 void __iomem *regs = musb->control_ep->regs; 438 void __iomem *regs = musb->control_ep->regs;
439 struct usb_request *req; 439 struct usb_request *req;
440 u16 tmp; 440 u16 count, csr;
441 441
442 req = next_ep0_request(musb); 442 req = next_ep0_request(musb);
443 443
@@ -449,35 +449,35 @@ static void ep0_rxstate(struct musb *musb)
449 unsigned len = req->length - req->actual; 449 unsigned len = req->length - req->actual;
450 450
451 /* read the buffer */ 451 /* read the buffer */
452 tmp = musb_readb(regs, MUSB_COUNT0); 452 count = musb_readb(regs, MUSB_COUNT0);
453 if (tmp > len) { 453 if (count > len) {
454 req->status = -EOVERFLOW; 454 req->status = -EOVERFLOW;
455 tmp = len; 455 count = len;
456 } 456 }
457 musb_read_fifo(&musb->endpoints[0], tmp, buf); 457 musb_read_fifo(&musb->endpoints[0], count, buf);
458 req->actual += tmp; 458 req->actual += count;
459 tmp = MUSB_CSR0_P_SVDRXPKTRDY; 459 csr = MUSB_CSR0_P_SVDRXPKTRDY;
460 if (tmp < 64 || req->actual == req->length) { 460 if (count < 64 || req->actual == req->length) {
461 musb->ep0_state = MUSB_EP0_STAGE_STATUSIN; 461 musb->ep0_state = MUSB_EP0_STAGE_STATUSIN;
462 tmp |= MUSB_CSR0_P_DATAEND; 462 csr |= MUSB_CSR0_P_DATAEND;
463 } else 463 } else
464 req = NULL; 464 req = NULL;
465 } else 465 } else
466 tmp = MUSB_CSR0_P_SVDRXPKTRDY | MUSB_CSR0_P_SENDSTALL; 466 csr = MUSB_CSR0_P_SVDRXPKTRDY | MUSB_CSR0_P_SENDSTALL;
467 467
468 468
469 /* Completion handler may choose to stall, e.g. because the 469 /* Completion handler may choose to stall, e.g. because the
470 * message just received holds invalid data. 470 * message just received holds invalid data.
471 */ 471 */
472 if (req) { 472 if (req) {
473 musb->ackpend = tmp; 473 musb->ackpend = csr;
474 musb_g_ep0_giveback(musb, req); 474 musb_g_ep0_giveback(musb, req);
475 if (!musb->ackpend) 475 if (!musb->ackpend)
476 return; 476 return;
477 musb->ackpend = 0; 477 musb->ackpend = 0;
478 } 478 }
479 musb_ep_select(musb->mregs, 0); 479 musb_ep_select(musb->mregs, 0);
480 musb_writew(regs, MUSB_CSR0, tmp); 480 musb_writew(regs, MUSB_CSR0, csr);
481} 481}
482 482
483/* 483/*