/*
* Immediately complete a request.
*
- * @param pRequest the request to complete
+ * @param request the request to complete
* @param status the status to complete the request with
* Context: controller locked, IRQs blocked.
*/
void musb_g_giveback(
struct musb_ep *ep,
- struct usb_request *pRequest,
+ struct usb_request *request,
int status)
__releases(ep->musb->lock)
__acquires(ep->musb->lock)
struct musb *musb;
int busy = ep->busy;
- req = to_musb_request(pRequest);
+ req = to_musb_request(request);
- list_del(&pRequest->list);
+ list_del(&request->list);
if (req->request.status == -EINPROGRESS)
req->request.status = status;
musb = req->musb;
? DMA_TO_DEVICE
: DMA_FROM_DEVICE);
}
- if (pRequest->status == 0)
+ if (request->status == 0)
DBG(5, "%s done request %p, %d/%d\n",
- ep->end_point.name, pRequest,
+ ep->end_point.name, request,
req->request.actual, req->request.length);
else
DBG(2, "%s request %p, %d/%d fault %d\n",
- ep->end_point.name, pRequest,
+ ep->end_point.name, request,
req->request.actual, req->request.length,
- pRequest->status);
+ request->status);
req->request.complete(&req->ep->end_point, &req->request);
spin_lock(&musb->lock);
ep->busy = busy;
u8 epnum = req->epnum;
struct musb_ep *musb_ep;
void __iomem *epio = musb->endpoints[epnum].regs;
- struct usb_request *pRequest;
+ struct usb_request *request;
u16 fifo_count = 0, wCsrVal;
int use_dma = 0;
/* read TXCSR before */
wCsrVal = musb_readw(epio, MGC_O_HDRC_TXCSR);
- pRequest = &req->request;
+ request = &req->request;
fifo_count = min(max_ep_writesize(musb, musb_ep),
- (int)(pRequest->length - pRequest->actual));
+ (int)(request->length - request->actual));
if (wCsrVal & MGC_M_TXCSR_TXPKTRDY) {
DBG(5, "%s old packet still ready , txcsr %03x\n",
if (is_dma_capable() && musb_ep->dma) {
struct dma_controller *c = musb->dma_controller;
- use_dma = (pRequest->dma != DMA_ADDR_INVALID);
+ use_dma = (request->dma != DMA_ADDR_INVALID);
/* MGC_M_TXCSR_P_ISO is still set correctly */
size_t request_size;
/* setup DMA, then program endpoint CSR */
- request_size = min(pRequest->length,
+ request_size = min(request->length,
musb_ep->dma->max_len);
if (request_size <= musb_ep->wPacketSize)
musb_ep->dma->desired_mode = 0;
use_dma = use_dma && c->channel_program(
musb_ep->dma, musb_ep->wPacketSize,
musb_ep->dma->desired_mode,
- pRequest->dma, request_size);
+ request->dma, request_size);
if (use_dma) {
if (musb_ep->dma->desired_mode == 0) {
/* ASSERT: DMAENAB is clear */
use_dma = use_dma && c->channel_program(
musb_ep->dma, musb_ep->wPacketSize,
0,
- pRequest->dma,
- pRequest->length);
+ request->dma,
+ request->length);
if (!use_dma) {
c->channel_release(musb_ep->dma);
musb_ep->dma = NULL;
#elif defined(CONFIG_USB_TUSB_OMAP_DMA)
use_dma = use_dma && c->channel_program(
musb_ep->dma, musb_ep->wPacketSize,
- pRequest->zero,
- pRequest->dma,
- pRequest->length);
+ request->zero,
+ request->dma,
+ request->length);
#endif
}
#endif
if (!use_dma) {
musb_write_fifo(musb_ep->hw_ep, fifo_count,
- (u8 *) (pRequest->buf + pRequest->actual));
- pRequest->actual += fifo_count;
+ (u8 *) (request->buf + request->actual));
+ request->actual += fifo_count;
wCsrVal |= MGC_M_TXCSR_TXPKTRDY;
wCsrVal &= ~MGC_M_TXCSR_P_UNDERRUN;
musb_writew(epio, MGC_O_HDRC_TXCSR, wCsrVal);
/* host may already have the data when this message shows... */
DBG(3, "%s TX/IN %s len %d/%d, txcsr %04x, fifo %d/%d\n",
musb_ep->end_point.name, use_dma ? "dma" : "pio",
- pRequest->actual, pRequest->length,
+ request->actual, request->length,
musb_readw(epio, MGC_O_HDRC_TXCSR),
fifo_count,
musb_readw(epio, MGC_O_HDRC_TXMAXP));
void musb_g_tx(struct musb *musb, u8 epnum)
{
u16 wCsrVal;
- struct usb_request *pRequest;
+ struct usb_request *request;
u8 __iomem *mbase = musb->mregs;
struct musb_ep *musb_ep = &musb->endpoints[epnum].ep_in;
void __iomem *epio = musb->endpoints[epnum].regs;
struct dma_channel *dma;
musb_ep_select(mbase, epnum);
- pRequest = next_request(musb_ep);
+ request = next_request(musb_ep);
wCsrVal = musb_readw(epio, MGC_O_HDRC_TXCSR);
DBG(4, "<== %s, txcsr %04x\n", musb_ep->end_point.name, wCsrVal);
musb->dma_controller->channel_abort(dma);
}
- if (pRequest)
- musb_g_giveback(musb_ep, pRequest, -EPIPE);
+ if (request)
+ musb_g_giveback(musb_ep, request, -EPIPE);
break;
}
wCsrVal &= ~(MGC_M_TXCSR_P_UNDERRUN
| MGC_M_TXCSR_TXPKTRDY);
musb_writew(epio, MGC_O_HDRC_TXCSR, wCsrVal);
- DBG(20, "underrun on ep%d, req %p\n", epnum, pRequest);
+ DBG(20, "underrun on ep%d, req %p\n", epnum, request);
}
if (dma_channel_status(dma) == MGC_DMA_STATUS_BUSY) {
break;
}
- if (pRequest) {
+ if (request) {
u8 is_dma = 0;
if (dma && (wCsrVal & MGC_M_TXCSR_DMAENAB)) {
musb_writew(epio, MGC_O_HDRC_TXCSR, wCsrVal);
/* ensure writebuffer is empty */
wCsrVal = musb_readw(epio, MGC_O_HDRC_TXCSR);
- pRequest->actual += musb_ep->dma->actual_len;
+ request->actual += musb_ep->dma->actual_len;
DBG(4, "TXCSR%d %04x, dma off, "
"len %Zd, req %p\n",
epnum, wCsrVal,
musb_ep->dma->actual_len,
- pRequest);
+ request);
}
- if (is_dma || pRequest->actual == pRequest->length) {
+ if (is_dma || request->actual == request->length) {
/* First, maybe a terminating short packet.
* Some DMA engines might handle this by
* themselves.
*/
- if ((pRequest->zero
- && pRequest->length
- && (pRequest->length
+ if ((request->zero
+ && request->length
+ && (request->length
% musb_ep->wPacketSize)
== 0)
#ifdef CONFIG_USB_INVENTRA_DMA
|| (is_dma &&
((!dma->desired_mode) ||
- (pRequest->actual &
+ (request->actual &
(musb_ep->wPacketSize - 1))))
#endif
) {
musb_writew(epio, MGC_O_HDRC_TXCSR,
MGC_M_TXCSR_MODE
| MGC_M_TXCSR_TXPKTRDY);
- pRequest->zero = 0;
+ request->zero = 0;
}
/* ... or if not, then complete it */
- musb_g_giveback(musb_ep, pRequest, 0);
+ musb_g_giveback(musb_ep, request, 0);
/* kickstart next transfer if appropriate;
* the packet that just completed might not
wCsrVal = musb_readw(epio, MGC_O_HDRC_TXCSR);
if (wCsrVal & MGC_M_TXCSR_FIFONOTEMPTY)
break;
- pRequest = musb_ep->desc
+ request = musb_ep->desc
? next_request(musb_ep)
: NULL;
- if (!pRequest) {
+ if (!request) {
DBG(4, "%s idle now\n",
musb_ep->end_point.name);
break;
}
}
- txstate(musb, to_musb_request(pRequest));
+ txstate(musb, to_musb_request(request));
}
} while (0);
{
u16 wCsrVal = 0;
const u8 epnum = req->epnum;
- struct usb_request *pRequest = &req->request;
+ struct usb_request *request = &req->request;
struct musb_ep *musb_ep = &musb->endpoints[epnum].ep_out;
void __iomem *epio = musb->endpoints[epnum].regs;
u16 fifo_count = 0;
*/
if (c->channel_program(channel,
musb_ep->wPacketSize,
- !pRequest->short_not_ok,
- pRequest->dma + pRequest->actual,
- pRequest->length - pRequest->actual)) {
+ !request->short_not_ok,
+ request->dma + request->actual,
+ request->length - request->actual)) {
/* make sure that if an rxpkt arrived after the irq,
* the cppi engine will be ready to take it as soon
if (wCsrVal & MGC_M_RXCSR_RXPKTRDY) {
len = musb_readw(epio, MGC_O_HDRC_RXCOUNT);
- if (pRequest->actual < pRequest->length) {
+ if (request->actual < request->length) {
#ifdef CONFIG_USB_INVENTRA_DMA
if (is_dma_capable() && musb_ep->dma) {
struct dma_controller *c;
musb_writew(epio, MGC_O_HDRC_RXCSR,
wCsrVal);
- if (pRequest->actual < pRequest->length) {
+ if (request->actual < request->length) {
int transfer_size = 0;
#ifdef USE_MODE1
- transfer_size = min(pRequest->length,
+ transfer_size = min(request->length,
channel->max_len);
#else
transfer_size = len;
channel,
musb_ep->wPacketSize,
channel->desired_mode,
- pRequest->dma
- + pRequest->actual,
+ request->dma
+ + request->actual,
transfer_size);
}
}
#endif /* Mentor's USB */
- fifo_count = pRequest->length - pRequest->actual;
+ fifo_count = request->length - request->actual;
DBG(3, "%s OUT/RX pio fifo %d/%d, maxpacket %d\n",
musb_ep->end_point.name,
len, fifo_count,
if (tusb_dma_omap() && musb_ep->dma) {
struct dma_controller *c = musb->dma_controller;
struct dma_channel *channel = musb_ep->dma;
- u32 dma_addr = pRequest->dma + pRequest->actual;
+ u32 dma_addr = request->dma + request->actual;
int ret;
ret = c->channel_program(channel,
#endif
musb_read_fifo(musb_ep->hw_ep, fifo_count, (u8 *)
- (pRequest->buf + pRequest->actual));
- pRequest->actual += fifo_count;
+ (request->buf + request->actual));
+ request->actual += fifo_count;
/* REVISIT if we left anything in the fifo, flush
* it and report -EOVERFLOW
}
/* reach the end or short packet detected */
- if (pRequest->actual == pRequest->length || len < musb_ep->wPacketSize)
- musb_g_giveback(musb_ep, pRequest, 0);
+ if (request->actual == request->length || len < musb_ep->wPacketSize)
+ musb_g_giveback(musb_ep, request, 0);
}
/*
void musb_g_rx(struct musb *musb, u8 epnum)
{
u16 wCsrVal;
- struct usb_request *pRequest;
+ struct usb_request *request;
void __iomem *mbase = musb->mregs;
struct musb_ep *musb_ep = &musb->endpoints[epnum].ep_out;
void __iomem *epio = musb->endpoints[epnum].regs;
musb_ep_select(mbase, epnum);
- pRequest = next_request(musb_ep);
+ request = next_request(musb_ep);
wCsrVal = musb_readw(epio, MGC_O_HDRC_RXCSR);
dma = is_dma_capable() ? musb_ep->dma : NULL;
DBG(4, "<== %s, rxcsr %04x%s %p\n", musb_ep->end_point.name,
- wCsrVal, dma ? " (dma)" : "", pRequest);
+ wCsrVal, dma ? " (dma)" : "", request);
if (wCsrVal & MGC_M_RXCSR_P_SENTSTALL) {
if (dma_channel_status(dma) == MGC_DMA_STATUS_BUSY) {
dma->status = MGC_DMA_STATUS_CORE_ABORT;
(void) musb->dma_controller->channel_abort(dma);
- pRequest->actual += musb_ep->dma->actual_len;
+ request->actual += musb_ep->dma->actual_len;
}
wCsrVal |= MGC_M_RXCSR_P_WZC_BITS;
wCsrVal &= ~MGC_M_RXCSR_P_SENTSTALL;
musb_writew(epio, MGC_O_HDRC_RXCSR, wCsrVal);
- if (pRequest)
- musb_g_giveback(musb_ep, pRequest, -EPIPE);
+ if (request)
+ musb_g_giveback(musb_ep, request, -EPIPE);
goto done;
}
wCsrVal &= ~MGC_M_RXCSR_P_OVERRUN;
musb_writew(epio, MGC_O_HDRC_RXCSR, wCsrVal);
- DBG(3, "%s iso overrun on %p\n", musb_ep->name, pRequest);
- if (pRequest && pRequest->status == -EINPROGRESS)
- pRequest->status = -EOVERFLOW;
+ DBG(3, "%s iso overrun on %p\n", musb_ep->name, request);
+ if (request && request->status == -EINPROGRESS)
+ request->status = -EOVERFLOW;
}
if (wCsrVal & MGC_M_RXCSR_INCOMPRX) {
/* REVISIT not necessarily an error */
musb_writew(epio, MGC_O_HDRC_RXCSR,
MGC_M_RXCSR_P_WZC_BITS | wCsrVal);
- pRequest->actual += musb_ep->dma->actual_len;
+ request->actual += musb_ep->dma->actual_len;
DBG(4, "RXCSR%d %04x, dma off, %04x, len %Zd, req %p\n",
epnum, wCsrVal,
musb_readw(epio, MGC_O_HDRC_RXCSR),
- musb_ep->dma->actual_len, pRequest);
+ musb_ep->dma->actual_len, request);
#if defined(CONFIG_USB_INVENTRA_DMA) || defined(CONFIG_USB_TUSB_OMAP_DMA)
/* Autoclear doesn't clear RxPktRdy for short packets */
}
/* incomplete, and not short? wait for next IN packet */
- if ((pRequest->actual < pRequest->length)
+ if ((request->actual < request->length)
&& (musb_ep->dma->actual_len
== musb_ep->wPacketSize))
goto done;
#endif
- musb_g_giveback(musb_ep, pRequest, 0);
+ musb_g_giveback(musb_ep, request, 0);
- pRequest = next_request(musb_ep);
- if (!pRequest)
+ request = next_request(musb_ep);
+ if (!request)
goto done;
/* don't start more i/o till the stall clears */
/* analyze request if the ep is hot */
- if (pRequest)
- rxstate(musb, to_musb_request(pRequest));
+ if (request)
+ rxstate(musb, to_musb_request(request));
else
DBG(3, "packet waiting for %s%s request\n",
musb_ep->desc ? "" : "inactive ",
struct usb_request *musb_alloc_request(struct usb_ep *ep, gfp_t gfp_flags)
{
struct musb_ep *musb_ep = to_musb_ep(ep);
- struct musb_request *pRequest = NULL;
-
- pRequest = kzalloc(sizeof *pRequest, gfp_flags);
- if (pRequest) {
- INIT_LIST_HEAD(&pRequest->request.list);
- pRequest->request.dma = DMA_ADDR_INVALID;
- pRequest->epnum = musb_ep->current_epnum;
- pRequest->ep = musb_ep;
+ struct musb_request *request = NULL;
+
+ request = kzalloc(sizeof *request, gfp_flags);
+ if (request) {
+ INIT_LIST_HEAD(&request->request.list);
+ request->request.dma = DMA_ADDR_INVALID;
+ request->epnum = musb_ep->current_epnum;
+ request->ep = musb_ep;
}
- return &pRequest->request;
+ return &request->request;
}
/*
gfp_t gfp_flags)
{
struct musb_ep *musb_ep;
- struct musb_request *pRequest;
+ struct musb_request *request;
struct musb *musb;
int status = 0;
unsigned long lockflags;
musb_ep = to_musb_ep(ep);
musb = musb_ep->musb;
- pRequest = to_musb_request(req);
- pRequest->musb = musb;
+ request = to_musb_request(req);
+ request->musb = musb;
- if (pRequest->ep != musb_ep)
+ if (request->ep != musb_ep)
return -EINVAL;
DBG(4, "<== to %s request=%p\n", ep->name, req);
/* request is mine now... */
- pRequest->request.actual = 0;
- pRequest->request.status = -EINPROGRESS;
- pRequest->epnum = musb_ep->current_epnum;
- pRequest->bTx = musb_ep->is_in;
+ request->request.actual = 0;
+ request->request.status = -EINPROGRESS;
+ request->epnum = musb_ep->current_epnum;
+ request->bTx = musb_ep->is_in;
if (is_dma_capable() && musb_ep->dma) {
- if (pRequest->request.dma == DMA_ADDR_INVALID) {
- pRequest->request.dma = dma_map_single(
+ if (request->request.dma == DMA_ADDR_INVALID) {
+ request->request.dma = dma_map_single(
musb->controller,
- pRequest->request.buf,
- pRequest->request.length,
- pRequest->bTx
+ request->request.buf,
+ request->request.length,
+ request->bTx
? DMA_TO_DEVICE
: DMA_FROM_DEVICE);
- pRequest->mapped = 1;
+ request->mapped = 1;
} else {
dma_sync_single_for_device(musb->controller,
- pRequest->request.dma,
- pRequest->request.length,
- pRequest->bTx
+ request->request.dma,
+ request->request.length,
+ request->bTx
? DMA_TO_DEVICE
: DMA_FROM_DEVICE);
- pRequest->mapped = 0;
+ request->mapped = 0;
}
} else if (!req->buf) {
return -ENODATA;
} else
- pRequest->mapped = 0;
+ request->mapped = 0;
spin_lock_irqsave(&musb->lock, lockflags);
goto cleanup;
}
- /* add pRequest to the list */
- list_add_tail(&(pRequest->request.list), &(musb_ep->req_list));
+ /* add request to the list */
+ list_add_tail(&(request->request.list), &(musb_ep->req_list));
/* it this is the head of the queue, start i/o ... */
- if (!musb_ep->busy && &pRequest->request.list == musb_ep->req_list.next)
- musb_ep_restart(musb, pRequest);
+ if (!musb_ep->busy && &request->request.list == musb_ep->req_list.next)
+ musb_ep_restart(musb, request);
cleanup:
spin_unlock_irqrestore(&musb->lock, lockflags);
return status;
}
-static int musb_gadget_dequeue(struct usb_ep *ep, struct usb_request *pRequest)
+static int musb_gadget_dequeue(struct usb_ep *ep, struct usb_request *request)
{
struct musb_ep *musb_ep = to_musb_ep(ep);
struct usb_request *r;
int status = 0;
struct musb *musb = musb_ep->musb;
- if (!ep || !pRequest || to_musb_request(pRequest)->ep != musb_ep)
+ if (!ep || !request || to_musb_request(request)->ep != musb_ep)
return -EINVAL;
spin_lock_irqsave(&musb->lock, flags);
list_for_each_entry(r, &musb_ep->req_list, list) {
- if (r == pRequest)
+ if (r == request)
break;
}
- if (r != pRequest) {
- DBG(3, "request %p not queued to %s\n", pRequest, ep->name);
+ if (r != request) {
+ DBG(3, "request %p not queued to %s\n", request, ep->name);
status = -EINVAL;
goto done;
}
/* if the hardware doesn't have the request, easy ... */
- if (musb_ep->req_list.next != &pRequest->list || musb_ep->busy)
- musb_g_giveback(musb_ep, pRequest, -ECONNRESET);
+ if (musb_ep->req_list.next != &request->list || musb_ep->busy)
+ musb_g_giveback(musb_ep, request, -ECONNRESET);
/* ... else abort the dma transfer ... */
else if (is_dma_capable() && musb_ep->dma) {
else
status = -EBUSY;
if (status == 0)
- musb_g_giveback(musb_ep, pRequest, -ECONNRESET);
+ musb_g_giveback(musb_ep, request, -ECONNRESET);
} else {
/* NOTE: by sticking to easily tested hardware/driver states,
* we leave counting of in-flight packets imprecise.
*/
- musb_g_giveback(musb_ep, pRequest, -ECONNRESET);
+ musb_g_giveback(musb_ep, request, -ECONNRESET);
}
done:
void __iomem *mbase;
unsigned long flags;
u16 wCsr;
- struct musb_request *pRequest = NULL;
+ struct musb_request *request = NULL;
int status = 0;
if (!ep)
musb_ep_select(mbase, epnum);
/* cannot portably stall with non-empty FIFO */
- pRequest = to_musb_request(next_request(musb_ep));
+ request = to_musb_request(next_request(musb_ep));
if (value && musb_ep->is_in) {
wCsr = musb_readw(epio, MGC_O_HDRC_TXCSR);
if (wCsr & MGC_M_TXCSR_FIFONOTEMPTY) {
done:
/* maybe start the first request in the queue */
- if (!musb_ep->busy && !value && pRequest) {
+ if (!musb_ep->busy && !value && request) {
DBG(3, "restarting the request\n");
- musb_ep_restart(musb, pRequest);
+ musb_ep_restart(musb, request);
}
spin_unlock_irqrestore(&musb->lock, flags);