diff options
author | David Brownell <david-b@pacbell.net> | 2005-10-16 18:06:51 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-10-28 19:47:44 -0400 |
commit | cb97c5c9d0789d65d7ec42a80946fa9eb2ec5182 (patch) | |
tree | 825fd67b5f945b31a5649bcfa1eaf5543cf93e5c /drivers | |
parent | 1fcb4454cbada6dc495302172ac0412aa7d35fd4 (diff) |
[PATCH] omap_udc dma off-by-one fix
The change to make DMA work two bytes at a time omitted an important
tweak that affects the file_storage gadget: it needs to recognize when
the host writes an odd number of bytes. (The network layer ignores
such extra bytes.)
This patch resolves that issue by checking the relevant bit and adjusting
the rx byte count, so that for example a legal 13 byte request doesn't
morph into an illegal 14 byte one any more.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/gadget/omap_udc.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c index b7885dc0f42f..de8a89ae4bc3 100644 --- a/drivers/usb/gadget/omap_udc.c +++ b/drivers/usb/gadget/omap_udc.c | |||
@@ -691,7 +691,7 @@ static void next_out_dma(struct omap_ep *ep, struct omap_req *req) | |||
691 | } | 691 | } |
692 | 692 | ||
693 | static void | 693 | static void |
694 | finish_out_dma(struct omap_ep *ep, struct omap_req *req, int status) | 694 | finish_out_dma(struct omap_ep *ep, struct omap_req *req, int status, int one) |
695 | { | 695 | { |
696 | u16 count; | 696 | u16 count; |
697 | 697 | ||
@@ -699,6 +699,8 @@ finish_out_dma(struct omap_ep *ep, struct omap_req *req, int status) | |||
699 | ep->dma_counter = (u16) (req->req.dma + req->req.actual); | 699 | ep->dma_counter = (u16) (req->req.dma + req->req.actual); |
700 | count = dma_dest_len(ep, req->req.dma + req->req.actual); | 700 | count = dma_dest_len(ep, req->req.dma + req->req.actual); |
701 | count += req->req.actual; | 701 | count += req->req.actual; |
702 | if (one) | ||
703 | count--; | ||
702 | if (count <= req->req.length) | 704 | if (count <= req->req.length) |
703 | req->req.actual = count; | 705 | req->req.actual = count; |
704 | 706 | ||
@@ -747,7 +749,7 @@ static void dma_irq(struct omap_udc *udc, u16 irq_src) | |||
747 | if (!list_empty(&ep->queue)) { | 749 | if (!list_empty(&ep->queue)) { |
748 | req = container_of(ep->queue.next, | 750 | req = container_of(ep->queue.next, |
749 | struct omap_req, queue); | 751 | struct omap_req, queue); |
750 | finish_out_dma(ep, req, 0); | 752 | finish_out_dma(ep, req, 0, dman_stat & UDC_DMA_RX_SB); |
751 | } | 753 | } |
752 | UDC_IRQ_SRC_REG = UDC_RXN_EOT; | 754 | UDC_IRQ_SRC_REG = UDC_RXN_EOT; |
753 | 755 | ||
@@ -925,7 +927,7 @@ static void dma_channel_release(struct omap_ep *ep) | |||
925 | while (UDC_RXDMA_CFG_REG & mask) | 927 | while (UDC_RXDMA_CFG_REG & mask) |
926 | udelay(10); | 928 | udelay(10); |
927 | if (req) | 929 | if (req) |
928 | finish_out_dma(ep, req, -ECONNRESET); | 930 | finish_out_dma(ep, req, -ECONNRESET, 0); |
929 | } | 931 | } |
930 | omap_free_dma(ep->lch); | 932 | omap_free_dma(ep->lch); |
931 | ep->dma_channel = 0; | 933 | ep->dma_channel = 0; |