aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorVernon Sauder <vsauder@inhand.com>2009-03-20 04:44:50 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-03-24 19:20:45 -0400
commit4c24b6d045a9d355c95ca4e6beb10ce2fd263390 (patch)
tree6195af438de3c2d0cc89fdd3b7c18cdf9cadce58 /drivers/usb
parentab943a2e125b098489ccaa0166c2c52f8266d9ed (diff)
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>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/pxa27x_udc.c54
1 files changed, 24 insertions, 30 deletions
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index 91ba1e939475..8cc676ecbb23 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -748,13 +748,13 @@ static void req_done(struct pxa_ep *ep, struct pxa27x_request *req, int status)
748} 748}
749 749
750/** 750/**
751 * ep_end_out_req - Ends control endpoint in request 751 * ep_end_out_req - Ends endpoint OUT request
752 * @ep: physical endpoint 752 * @ep: physical endpoint
753 * @req: pxa request 753 * @req: pxa request
754 * 754 *
755 * Context: ep->lock held 755 * Context: ep->lock held
756 * 756 *
757 * Ends endpoint in request (completes usb request). 757 * Ends endpoint OUT request (completes usb request).
758 */ 758 */
759static void ep_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req) 759static void ep_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req)
760{ 760{
@@ -763,13 +763,13 @@ static void ep_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req)
763} 763}
764 764
765/** 765/**
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)
767 * @ep: physical endpoint 767 * @ep: physical endpoint
768 * @req: pxa request 768 * @req: pxa request
769 * 769 *
770 * Context: ep->lock held 770 * Context: ep->lock held
771 * 771 *
772 * Ends control endpoint in request (completes usb request), and puts 772 * Ends control endpoint OUT request (completes usb request), and puts
773 * control endpoint into idle state 773 * control endpoint into idle state
774 */ 774 */
775static void ep0_end_out_req(struct pxa_ep *ep, struct pxa27x_request *req) 775static 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)
780} 780}
781 781
782/** 782/**
783 * ep_end_in_req - Ends endpoint out request 783 * ep_end_in_req - Ends endpoint IN request
784 * @ep: physical endpoint 784 * @ep: physical endpoint
785 * @req: pxa request 785 * @req: pxa request
786 * 786 *
787 * Context: ep->lock held 787 * Context: ep->lock held
788 * 788 *
789 * Ends endpoint out request (completes usb request). 789 * Ends endpoint IN request (completes usb request).
790 */ 790 */
791static void ep_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req) 791static void ep_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req)
792{ 792{
@@ -795,20 +795,18 @@ static void ep_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req)
795} 795}
796 796
797/** 797/**
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)
799 * @ep: physical endpoint 799 * @ep: physical endpoint
800 * @req: pxa request 800 * @req: pxa request
801 * 801 *
802 * Context: ep->lock held 802 * Context: ep->lock held
803 * 803 *
804 * Ends control endpoint out request (completes usb request), and puts 804 * Ends control endpoint IN request (completes usb request), and puts
805 * control endpoint into status state 805 * control endpoint into status state
806 */ 806 */
807static void ep0_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req) 807static void ep0_end_in_req(struct pxa_ep *ep, struct pxa27x_request *req)
808{ 808{
809 struct pxa_udc *udc = ep->dev; 809 set_ep0state(ep->dev, IN_STATUS_STAGE);
810
811 set_ep0state(udc, IN_STATUS_STAGE);
812 ep_end_in_req(ep, req); 810 ep_end_in_req(ep, req);
813} 811}
814 812
@@ -1168,7 +1166,7 @@ static int pxa_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
1168 ep_end_in_req(ep, req); 1166 ep_end_in_req(ep, req);
1169 } else { 1167 } else {
1170 ep_err(ep, "got a request of %d bytes while" 1168 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",
1172 length); 1170 length);
1173 ep_del_request(ep, req); 1171 ep_del_request(ep, req);
1174 rc = -EL2HLT; 1172 rc = -EL2HLT;
@@ -1214,30 +1212,26 @@ static int pxa_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
1214 struct udc_usb_ep *udc_usb_ep; 1212 struct udc_usb_ep *udc_usb_ep;
1215 struct pxa27x_request *req; 1213 struct pxa27x_request *req;
1216 unsigned long flags; 1214 unsigned long flags;
1217 int rc; 1215 int rc = -EINVAL;
1218 1216
1219 if (!_ep) 1217 if (!_ep)
1220 return -EINVAL; 1218 return rc;
1221 udc_usb_ep = container_of(_ep, struct udc_usb_ep, usb_ep); 1219 udc_usb_ep = container_of(_ep, struct udc_usb_ep, usb_ep);
1222 ep = udc_usb_ep->pxa_ep; 1220 ep = udc_usb_ep->pxa_ep;
1223 if (!ep || is_ep0(ep)) 1221 if (!ep || is_ep0(ep))
1224 return -EINVAL; 1222 return rc;
1225 1223
1226 spin_lock_irqsave(&ep->lock, flags); 1224 spin_lock_irqsave(&ep->lock, flags);
1227 1225
1228 /* make sure it's actually queued on this endpoint */ 1226 /* make sure it's actually queued on this endpoint */
1229 list_for_each_entry(req, &ep->queue, queue) { 1227 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;
1231 break; 1231 break;
1232 }
1232 } 1233 }
1233 1234
1234 rc = -EINVAL;
1235 if (&req->req != _req)
1236 goto out;
1237
1238 rc = 0;
1239 req_done(ep, req, -ECONNRESET);
1240out:
1241 spin_unlock_irqrestore(&ep->lock, flags); 1235 spin_unlock_irqrestore(&ep->lock, flags);
1242 return rc; 1236 return rc;
1243} 1237}
@@ -1706,10 +1700,9 @@ static __init void udc_init_data(struct pxa_udc *dev)
1706 } 1700 }
1707 1701
1708 /* USB endpoints init */ 1702 /* USB endpoints init */
1709 for (i = 0; i < NR_USB_ENDPOINTS; i++) 1703 for (i = 1; i < NR_USB_ENDPOINTS; i++)
1710 if (i != 0) 1704 list_add_tail(&dev->udc_usb_ep[i].usb_ep.ep_list,
1711 list_add_tail(&dev->udc_usb_ep[i].usb_ep.ep_list, 1705 &dev->gadget.ep_list);
1712 &dev->gadget.ep_list);
1713} 1706}
1714 1707
1715/** 1708/**
@@ -1994,14 +1987,14 @@ static void handle_ep0(struct pxa_udc *udc, int fifo_irq, int opc_irq)
1994 struct pxa27x_request *req = NULL; 1987 struct pxa27x_request *req = NULL;
1995 int completed = 0; 1988 int completed = 0;
1996 1989
1990 if (!list_empty(&ep->queue))
1991 req = list_entry(ep->queue.next, struct pxa27x_request, queue);
1992
1997 udccsr0 = udc_ep_readl(ep, UDCCSR); 1993 udccsr0 = udc_ep_readl(ep, UDCCSR);
1998 ep_dbg(ep, "state=%s, req=%p, udccsr0=0x%03x, udcbcr=%d, irq_msk=%x\n", 1994 ep_dbg(ep, "state=%s, req=%p, udccsr0=0x%03x, udcbcr=%d, irq_msk=%x\n",
1999 EP0_STNAME(udc), req, udccsr0, udc_ep_readl(ep, UDCBCR), 1995 EP0_STNAME(udc), req, udccsr0, udc_ep_readl(ep, UDCBCR),
2000 (fifo_irq << 1 | opc_irq)); 1996 (fifo_irq << 1 | opc_irq));
2001 1997
2002 if (!list_empty(&ep->queue))
2003 req = list_entry(ep->queue.next, struct pxa27x_request, queue);
2004
2005 if (udccsr0 & UDCCSR0_SST) { 1998 if (udccsr0 & UDCCSR0_SST) {
2006 ep_dbg(ep, "clearing stall status\n"); 1999 ep_dbg(ep, "clearing stall status\n");
2007 nuke(ep, -EPIPE); 2000 nuke(ep, -EPIPE);
@@ -2473,6 +2466,7 @@ static int __exit pxa_udc_remove(struct platform_device *_dev)
2473 platform_set_drvdata(_dev, NULL); 2466 platform_set_drvdata(_dev, NULL);
2474 the_controller = NULL; 2467 the_controller = NULL;
2475 clk_put(udc->clk); 2468 clk_put(udc->clk);
2469 iounmap(udc->regs);
2476 2470
2477 return 0; 2471 return 0;
2478} 2472}