From patchwork Thu Sep 3 17:01:34 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 45400 Received: from arroyo.ext.ti.com (arroyo.ext.ti.com [192.94.94.40]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n83H2MEQ013988 for ; Thu, 3 Sep 2009 17:02:22 GMT Received: from dlep34.itg.ti.com ([157.170.170.115]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id n83H0Fww022993; Thu, 3 Sep 2009 12:00:20 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep34.itg.ti.com (8.13.7/8.13.7) with ESMTP id n83H0ElU020877; Thu, 3 Sep 2009 12:00:14 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id C522380627; Thu, 3 Sep 2009 12:00:14 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp52.itg.ti.com (dflp52.itg.ti.com [128.247.22.96]) by linux.omap.com (Postfix) with ESMTP id A85E180626 for ; Thu, 3 Sep 2009 12:00:13 -0500 (CDT) Received: from neches.ext.ti.com (localhost [127.0.0.1]) by dflp52.itg.ti.com (8.13.7/8.13.7) with ESMTP id n83H0D9G001275 for ; Thu, 3 Sep 2009 12:00:13 -0500 (CDT) Received: from mail153-va3-R.bigfish.com (mail-va3.bigfish.com [216.32.180.114]) by neches.ext.ti.com (8.13.7/8.13.7) with ESMTP id n83H08s7003164 for ; Thu, 3 Sep 2009 12:00:13 -0500 Received: from mail153-va3 (localhost.localdomain [127.0.0.1]) by mail153-va3-R.bigfish.com (Postfix) with ESMTP id B177D7483DA for ; Thu, 3 Sep 2009 17:00:07 +0000 (UTC) X-SpamScore: -5 X-BigFish: vps-5(zz936eMzz1202hzzz2dh6bh62h) X-Spam-TCS-SCL: 1:0 X-FB-SS: 5, X-MS-Exchange-Organization-Antispam-Report: OrigIP: 63.81.120.155; Service: EHS Received: by mail153-va3 (MessageSwitch) id 1251997199871596_22498; Thu, 3 Sep 2009 16:59:59 +0000 (UCT) Received: from imap.sh.mvista.com (unknown [63.81.120.155]) by mail153-va3.bigfish.com (Postfix) with ESMTP id C3543CF80B3 for ; Thu, 3 Sep 2009 16:59:43 +0000 (UTC) Received: from wasted.dev.rtsoft.ru (unknown [10.150.0.9]) by imap.sh.mvista.com (Postfix) with ESMTP id 9C7703EC9; Thu, 3 Sep 2009 09:59:39 -0700 (PDT) From: Sergei Shtylyov Organization: MontaVista Software Inc. To: gregkh@suse.de, david-b@pacbell.net Date: Thu, 3 Sep 2009 20:01:34 +0300 User-Agent: KMail/1.5 MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200909032101.34736.sshtylyov@ru.mvista.com> Cc: davinci-linux-open-source@linux.davincidsp.com, linux-usb@vger.kernel.org Subject: [PATCH 3/4] musb_gadget_ep0: stop abusing musb_gadget_set_halt() X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.4 Precedence: list List-Id: davinci-linux-open-source.linux.davincidsp.com List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com Stop playing with musb->lock and abusing musb_gadget_set_halt() in the code clearing the endpoint halt feature -- instead, manipulate the registers directly. While at it, get rid uf unneeded line breaks and over-indentation in the code setting the endpoint halt feature. Signed-off-by: Sergei Shtylyov --- The patch is against the recent Linus' tree. This is probably 2.6.32 material... drivers/usb/musb/musb_gadget.h | 2 - drivers/usb/musb/musb_gadget_ep0.c | 63 ++++++++++++++++++++++--------------- 2 files changed, 38 insertions(+), 27 deletions(-) Index: linux-2.6/drivers/usb/musb/musb_gadget.h =================================================================== --- linux-2.6.orig/drivers/usb/musb/musb_gadget.h +++ linux-2.6/drivers/usb/musb/musb_gadget.h @@ -103,6 +103,4 @@ extern void musb_gadget_cleanup(struct m extern void musb_g_giveback(struct musb_ep *, struct usb_request *, int); -extern int musb_gadget_set_halt(struct usb_ep *ep, int value); - #endif /* __MUSB_GADGET_H */ Index: linux-2.6/drivers/usb/musb/musb_gadget_ep0.c =================================================================== --- linux-2.6.orig/drivers/usb/musb/musb_gadget_ep0.c +++ linux-2.6/drivers/usb/musb/musb_gadget_ep0.c @@ -258,19 +258,25 @@ __acquires(musb->lock) case USB_RECIP_INTERFACE: break; case USB_RECIP_ENDPOINT:{ - const u8 num = ctrlrequest->wIndex & 0x0f; - struct musb_ep *musb_ep; + const u8 epnum = + ctrlrequest->wIndex & 0x0f; + struct musb_ep *musb_ep; + struct musb_hw_ep *ep; + void __iomem *regs; + int is_in; + u16 csr; - if (num == 0 - || num >= MUSB_C_NUM_EPS - || ctrlrequest->wValue - != USB_ENDPOINT_HALT) + if (epnum == 0 || epnum >= MUSB_C_NUM_EPS || + ctrlrequest->wValue != USB_ENDPOINT_HALT) break; - if (ctrlrequest->wIndex & USB_DIR_IN) - musb_ep = &musb->endpoints[num].ep_in; + ep = musb->endpoints + epnum; + regs = ep->regs; + is_in = ctrlrequest->wIndex & USB_DIR_IN; + if (is_in) + musb_ep = &ep->ep_in; else - musb_ep = &musb->endpoints[num].ep_out; + musb_ep = &ep->ep_out; if (!musb_ep->desc) break; @@ -279,10 +285,23 @@ __acquires(musb->lock) if (musb_ep->wedged) break; - /* REVISIT do it directly, no locking games */ - spin_unlock(&musb->lock); - musb_gadget_set_halt(&musb_ep->end_point, 0); - spin_lock(&musb->lock); + musb_ep_select(mbase, epnum); + if (is_in) { + csr = musb_readw(regs, MUSB_TXCSR); + csr |= MUSB_TXCSR_CLRDATATOG | + MUSB_TXCSR_P_WZC_BITS; + csr &= ~(MUSB_TXCSR_P_SENDSTALL | + MUSB_TXCSR_P_SENTSTALL | + MUSB_TXCSR_TXPKTRDY); + musb_writew(regs, MUSB_TXCSR, csr); + } else { + csr = musb_readw(regs, MUSB_RXCSR); + csr |= MUSB_RXCSR_CLRDATATOG | + MUSB_RXCSR_P_WZC_BITS; + csr &= ~(MUSB_RXCSR_P_SENDSTALL | + MUSB_RXCSR_P_SENTSTALL); + musb_writew(regs, MUSB_RXCSR, csr); + } /* select ep0 again */ musb_ep_select(mbase, 0); @@ -378,10 +397,8 @@ stall: int is_in; u16 csr; - if (epnum == 0 - || epnum >= MUSB_C_NUM_EPS - || ctrlrequest->wValue - != USB_ENDPOINT_HALT) + if (epnum == 0 || epnum >= MUSB_C_NUM_EPS || + ctrlrequest->wValue != USB_ENDPOINT_HALT) break; ep = musb->endpoints + epnum; @@ -396,24 +413,20 @@ stall: musb_ep_select(mbase, epnum); if (is_in) { - csr = musb_readw(regs, - MUSB_TXCSR); + csr = musb_readw(regs, MUSB_TXCSR); if (csr & MUSB_TXCSR_FIFONOTEMPTY) csr |= MUSB_TXCSR_FLUSHFIFO; csr |= MUSB_TXCSR_P_SENDSTALL | MUSB_TXCSR_CLRDATATOG | MUSB_TXCSR_P_WZC_BITS; - musb_writew(regs, MUSB_TXCSR, - csr); + musb_writew(regs, MUSB_TXCSR, csr); } else { - csr = musb_readw(regs, - MUSB_RXCSR); + csr = musb_readw(regs, MUSB_RXCSR); csr |= MUSB_RXCSR_P_SENDSTALL | MUSB_RXCSR_FLUSHFIFO | MUSB_RXCSR_CLRDATATOG | MUSB_RXCSR_P_WZC_BITS; - musb_writew(regs, MUSB_RXCSR, - csr); + musb_writew(regs, MUSB_RXCSR, csr); } /* select ep0 again */