Skip to content

Commit 4c24b6d

Browse files
Vernon Saudergregkh
authored andcommitted
USB: pxa27x_udc: typo fixes and code cleanups
This patch is a merge of patches : - fix function doc and debug - cleanup loop count - optimize code to remove local variable and extra check - init 'req' before use - add missing iounmap call [dbrownell@users.sourceforge.net: capitalize IN/OUT directions in doc] Signed-off-by: Vernon Sauder <vsauder@inhand.com> [folded by Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent ab943a2 commit 4c24b6d

File tree

1 file changed

+24
-30
lines changed

1 file changed

+24
-30
lines changed

drivers/usb/gadget/pxa27x_udc.c

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -748,13 +748,13 @@ static void req_done(struct pxa_ep *ep, struct pxa27x_request *req, int status)
748748
}
749749

750750
/**
751-
* ep_end_out_req - Ends control endpoint in request
751+
* ep_end_out_req - Ends endpoint OUT request
752752
* @ep: physical endpoint
753753
* @req: pxa request
754754
*
755755
* Context: ep->lock held
756756
*
757-
* Ends endpoint in request (completes usb request).
757+
* Ends endpoint OUT request (completes usb request).
758758
*/
759759
static void ep_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req)
760760
{
@@ -763,13 +763,13 @@ static void ep_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req)
763763
}
764764

765765
/**
766-
* ep0_end_out_req - Ends control endpoint in request (ends data stage)
766+
* ep0_end_out_req - Ends control endpoint OUT request (ends data stage)
767767
* @ep: physical endpoint
768768
* @req: pxa request
769769
*
770770
* Context: ep->lock held
771771
*
772-
* Ends control endpoint in request (completes usb request), and puts
772+
* Ends control endpoint OUT request (completes usb request), and puts
773773
* control endpoint into idle state
774774
*/
775775
static void ep0_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req)
@@ -780,13 +780,13 @@ static void ep0_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req)
780780
}
781781

782782
/**
783-
* ep_end_in_req - Ends endpoint out request
783+
* ep_end_in_req - Ends endpoint IN request
784784
* @ep: physical endpoint
785785
* @req: pxa request
786786
*
787787
* Context: ep->lock held
788788
*
789-
* Ends endpoint out request (completes usb request).
789+
* Ends endpoint IN request (completes usb request).
790790
*/
791791
static void ep_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req)
792792
{
@@ -795,20 +795,18 @@ static void ep_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req)
795795
}
796796

797797
/**
798-
* ep0_end_in_req - Ends control endpoint out request (ends data stage)
798+
* ep0_end_in_req - Ends control endpoint IN request (ends data stage)
799799
* @ep: physical endpoint
800800
* @req: pxa request
801801
*
802802
* Context: ep->lock held
803803
*
804-
* Ends control endpoint out request (completes usb request), and puts
804+
* Ends control endpoint IN request (completes usb request), and puts
805805
* control endpoint into status state
806806
*/
807807
static void ep0_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req)
808808
{
809-
struct pxa_udc *udc = ep->dev;
810-
811-
set_ep0state(udc, IN_STATUS_STAGE);
809+
set_ep0state(ep->dev, IN_STATUS_STAGE);
812810
ep_end_in_req(ep, req);
813811
}
814812

@@ -1168,7 +1166,7 @@ static int pxa_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
11681166
ep_end_in_req(ep, req);
11691167
} else {
11701168
ep_err(ep, "got a request of %d bytes while"
1171-
"in state WATI_ACK_SET_CONF_INTERF\n",
1169+
"in state WAIT_ACK_SET_CONF_INTERF\n",
11721170
length);
11731171
ep_del_request(ep, req);
11741172
rc = -EL2HLT;
@@ -1214,30 +1212,26 @@ static int pxa_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
12141212
struct udc_usb_ep *udc_usb_ep;
12151213
struct pxa27x_request *req;
12161214
unsigned long flags;
1217-
int rc;
1215+
int rc = -EINVAL;
12181216

12191217
if (!_ep)
1220-
return -EINVAL;
1218+
return rc;
12211219
udc_usb_ep = container_of(_ep, struct udc_usb_ep, usb_ep);
12221220
ep = udc_usb_ep->pxa_ep;
12231221
if (!ep || is_ep0(ep))
1224-
return -EINVAL;
1222+
return rc;
12251223

12261224
spin_lock_irqsave(&ep->lock, flags);
12271225

12281226
/* make sure it's actually queued on this endpoint */
12291227
list_for_each_entry(req, &ep->queue, queue) {
1230-
if (&req->req == _req)
1228+
if (&req->req == _req) {
1229+
req_done(ep, req, -ECONNRESET);
1230+
rc = 0;
12311231
break;
1232+
}
12321233
}
12331234

1234-
rc = -EINVAL;
1235-
if (&req->req != _req)
1236-
goto out;
1237-
1238-
rc = 0;
1239-
req_done(ep, req, -ECONNRESET);
1240-
out:
12411235
spin_unlock_irqrestore(&ep->lock, flags);
12421236
return rc;
12431237
}
@@ -1706,10 +1700,9 @@ static __init void udc_init_data(struct pxa_udc *dev)
17061700
}
17071701

17081702
/* USB endpoints init */
1709-
for (i = 0; i < NR_USB_ENDPOINTS; i++)
1710-
if (i != 0)
1711-
list_add_tail(&dev->udc_usb_ep[i].usb_ep.ep_list,
1712-
&dev->gadget.ep_list);
1703+
for (i = 1; i < NR_USB_ENDPOINTS; i++)
1704+
list_add_tail(&dev->udc_usb_ep[i].usb_ep.ep_list,
1705+
&dev->gadget.ep_list);
17131706
}
17141707

17151708
/**
@@ -1994,14 +1987,14 @@ static void handle_ep0(struct pxa_udc *udc, int fifo_irq, int opc_irq)
19941987
struct pxa27x_request *req = NULL;
19951988
int completed = 0;
19961989

1990+
if (!list_empty(&ep->queue))
1991+
req = list_entry(ep->queue.next, struct pxa27x_request, queue);
1992+
19971993
udccsr0 = udc_ep_readl(ep, UDCCSR);
19981994
ep_dbg(ep, "state=%s, req=%p, udccsr0=0x%03x, udcbcr=%d, irq_msk=%x\n",
19991995
EP0_STNAME(udc), req, udccsr0, udc_ep_readl(ep, UDCBCR),
20001996
(fifo_irq << 1 | opc_irq));
20011997

2002-
if (!list_empty(&ep->queue))
2003-
req = list_entry(ep->queue.next, struct pxa27x_request, queue);
2004-
20051998
if (udccsr0 & UDCCSR0_SST) {
20061999
ep_dbg(ep, "clearing stall status\n");
20072000
nuke(ep, -EPIPE);
@@ -2473,6 +2466,7 @@ static int __exit pxa_udc_remove(struct platform_device *_dev)
24732466
platform_set_drvdata(_dev, NULL);
24742467
the_controller = NULL;
24752468
clk_put(udc->clk);
2469+
iounmap(udc->regs);
24762470

24772471
return 0;
24782472
}

0 commit comments

Comments
 (0)