Commit 64ca44a65adf131c4df5124fe0fcdc3896f0f0dc
Committed by
Greg Kroah-Hartman
1 parent
2492e6747f
Exists in
master
and in
7 other branches
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>
Showing 1 changed file with 12 additions and 12 deletions Side-by-side Diff
drivers/usb/musb/musb_gadget_ep0.c
... | ... | @@ -437,7 +437,7 @@ |
437 | 437 | { |
438 | 438 | void __iomem *regs = musb->control_ep->regs; |
439 | 439 | struct usb_request *req; |
440 | - u16 tmp; | |
440 | + u16 count, csr; | |
441 | 441 | |
442 | 442 | req = next_ep0_request(musb); |
443 | 443 | |
444 | 444 | |
445 | 445 | |
446 | 446 | |
447 | 447 | |
448 | 448 | |
449 | 449 | |
... | ... | @@ -449,35 +449,35 @@ |
449 | 449 | unsigned len = req->length - req->actual; |
450 | 450 | |
451 | 451 | /* read the buffer */ |
452 | - tmp = musb_readb(regs, MUSB_COUNT0); | |
453 | - if (tmp > len) { | |
452 | + count = musb_readb(regs, MUSB_COUNT0); | |
453 | + if (count > len) { | |
454 | 454 | req->status = -EOVERFLOW; |
455 | - tmp = len; | |
455 | + count = len; | |
456 | 456 | } |
457 | - musb_read_fifo(&musb->endpoints[0], tmp, buf); | |
458 | - req->actual += tmp; | |
459 | - tmp = MUSB_CSR0_P_SVDRXPKTRDY; | |
460 | - if (tmp < 64 || req->actual == req->length) { | |
457 | + musb_read_fifo(&musb->endpoints[0], count, buf); | |
458 | + req->actual += count; | |
459 | + csr = MUSB_CSR0_P_SVDRXPKTRDY; | |
460 | + if (count < 64 || req->actual == req->length) { | |
461 | 461 | musb->ep0_state = MUSB_EP0_STAGE_STATUSIN; |
462 | - tmp |= MUSB_CSR0_P_DATAEND; | |
462 | + csr |= MUSB_CSR0_P_DATAEND; | |
463 | 463 | } else |
464 | 464 | req = NULL; |
465 | 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 | 469 | /* Completion handler may choose to stall, e.g. because the |
470 | 470 | * message just received holds invalid data. |
471 | 471 | */ |
472 | 472 | if (req) { |
473 | - musb->ackpend = tmp; | |
473 | + musb->ackpend = csr; | |
474 | 474 | musb_g_ep0_giveback(musb, req); |
475 | 475 | if (!musb->ackpend) |
476 | 476 | return; |
477 | 477 | musb->ackpend = 0; |
478 | 478 | } |
479 | 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 | /* |