Skip to content

Commit

Permalink
usb: musb: gadget: use variables according to their names in rxstate()
Browse files Browse the repository at this point in the history
In rxstate(), improper types are given to 'fifo_count' and 'len' variables, and
these variables are not used in accordance to their names (up to the certain
point), i.e. 'len' to hold the size of a packet in the RX FIFO, and 'fifo_count'
to hold a difference between 'request->length' and 'request->actual'...
Interchange the variables up to the point where their use starts to make sense
again.

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Sergei Shtylyov authored and Felipe Balbi committed Aug 3, 2012
1 parent 0d7614f commit f0443af
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions drivers/usb/musb/musb_gadget.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,8 @@ static void rxstate(struct musb *musb, struct musb_request *req)
struct usb_request *request = &req->request;
struct musb_ep *musb_ep;
void __iomem *epio = musb->endpoints[epnum].regs;
unsigned fifo_count = 0;
u16 len;
unsigned len = 0;
u16 fifo_count;
u16 csr = musb_readw(epio, MUSB_RXCSR);
struct musb_hw_ep *hw_ep = &musb->endpoints[epnum];
u8 use_mode_1;
Expand All @@ -655,7 +655,7 @@ static void rxstate(struct musb *musb, struct musb_request *req)
else
musb_ep = &hw_ep->ep_out;

len = musb_ep->packet_sz;
fifo_count = musb_ep->packet_sz;

/* Check if EP is disabled */
if (!musb_ep->desc) {
Expand Down Expand Up @@ -704,15 +704,15 @@ static void rxstate(struct musb *musb, struct musb_request *req)
}

if (csr & MUSB_RXCSR_RXPKTRDY) {
len = musb_readw(epio, MUSB_RXCOUNT);
fifo_count = musb_readw(epio, MUSB_RXCOUNT);

/*
* Enable Mode 1 on RX transfers only when short_not_ok flag
* is set. Currently short_not_ok flag is set only from
* file_storage and f_mass_storage drivers
*/

if (request->short_not_ok && len == musb_ep->packet_sz)
if (request->short_not_ok && fifo_count == musb_ep->packet_sz)
use_mode_1 = 1;
else
use_mode_1 = 0;
Expand Down Expand Up @@ -780,7 +780,7 @@ static void rxstate(struct musb *musb, struct musb_request *req)
musb_ep->dma->desired_mode = 1;
} else {
transfer_size = min(request->length - request->actual,
(unsigned)len);
(unsigned)fifo_count);
musb_ep->dma->desired_mode = 0;
}

Expand Down Expand Up @@ -808,16 +808,16 @@ static void rxstate(struct musb *musb, struct musb_request *req)
channel = musb_ep->dma;

/* In case first packet is short */
if (len < musb_ep->packet_sz)
transfer_size = len;
if (fifo_count < musb_ep->packet_sz)
transfer_size = fifo_count;
else if (request->short_not_ok)
transfer_size = min(request->length -
request->actual,
channel->max_len);
else
transfer_size = min(request->length -
request->actual,
(unsigned)len);
(unsigned)fifo_count);

csr &= ~MUSB_RXCSR_DMAMODE;
csr |= (MUSB_RXCSR_DMAENAB |
Expand Down Expand Up @@ -845,10 +845,10 @@ static void rxstate(struct musb *musb, struct musb_request *req)
}
#endif /* Mentor's DMA */

fifo_count = request->length - request->actual;
len = request->length - request->actual;
dev_dbg(musb->controller, "%s OUT/RX pio fifo %d/%d, maxpacket %d\n",
musb_ep->end_point.name,
len, fifo_count,
fifo_count, len,
musb_ep->packet_sz);

fifo_count = min_t(unsigned, len, fifo_count);
Expand Down Expand Up @@ -901,7 +901,8 @@ static void rxstate(struct musb *musb, struct musb_request *req)
}

/* reach the end or short packet detected */
if (request->actual == request->length || len < musb_ep->packet_sz)
if (request->actual == request->length ||
fifo_count < musb_ep->packet_sz)
musb_g_giveback(musb_ep, request, 0);
}

Expand Down

0 comments on commit f0443af

Please sign in to comment.