From patchwork Tue Sep 7 15:23:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 161331 X-Patchwork-Delegate: me@felipebalbi.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o87FOaui003975 for ; Tue, 7 Sep 2010 15:24:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757524Ab0IGPYI (ORCPT ); Tue, 7 Sep 2010 11:24:08 -0400 Received: from mail-px0-f174.google.com ([209.85.212.174]:61953 "EHLO mail-px0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757363Ab0IGPYF (ORCPT ); Tue, 7 Sep 2010 11:24:05 -0400 Received: by mail-px0-f174.google.com with SMTP id 10so1361938pxi.19 for ; Tue, 07 Sep 2010 08:24:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=eey+ZAwH0Mv06XrNmW+xx3purtJEoa6OMbYAVw3EryY=; b=rtGZ4jt6zWmmEEyYJpxnkyOcTlFwF8ohBd3LJqMcFtnoJybKWYMsErxX03ghwaVWXm 8gN0Mcwf1Djll3k5LgzTd9jLbZK0DiUkBbTRDdeWhOBQiYGjUYKCtMdoP3k44AEKPepN yEV6zulqJgZgP7XC786pkDWtVP3JhAoD6BE9g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=UBo95bBwnbjhAktt7FxSK3dcXsPonLqAH+JGbDIXYnQs7wT8wG3JDtCSO026m6xjwn nqbLGDk96E/BoQ0H3Vu0fgghw4dJiWiEhxWtBOp8HvTOQXHxxNVL7gcfHbr50QEM/h6M vzenWEP9DAlKT9wrM5SpJbzABlow4Rh+mDaWY= Received: by 10.114.126.2 with SMTP id y2mr26362wac.57.1283873045050; Tue, 07 Sep 2010 08:24:05 -0700 (PDT) Received: from localhost ([183.16.32.111]) by mx.google.com with ESMTPS id q6sm13705732waj.10.2010.09.07.08.23.56 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 07 Sep 2010 08:24:03 -0700 (PDT) From: tom.leiming@gmail.com To: greg@kroah.com Cc: linux-usb@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, Ming Lei , David Brownell , Felipe Balbi , Anand Gadiyar , Mike Frysinger , Sergei Shtylyov , stable Subject: [RESEND/PATCH 1/6] USB: musb-gadget: fix kernel panic if using out ep with FIFO_TXRX style(v1) Date: Tue, 7 Sep 2010 23:23:29 +0800 Message-Id: <1283873014-32511-2-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 1.6.2.5 In-Reply-To: <1283873014-32511-1-git-send-email-tom.leiming@gmail.com> References: <1283873014-32511-1-git-send-email-tom.leiming@gmail.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 07 Sep 2010 15:24:36 +0000 (UTC) diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 6fca870..de0ca90 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -568,11 +568,19 @@ static void rxstate(struct musb *musb, struct musb_request *req) { const u8 epnum = req->epnum; struct usb_request *request = &req->request; - struct musb_ep *musb_ep = &musb->endpoints[epnum].ep_out; + struct musb_ep *musb_ep; void __iomem *epio = musb->endpoints[epnum].regs; unsigned fifo_count = 0; - u16 len = musb_ep->packet_sz; + u16 len; u16 csr = musb_readw(epio, MUSB_RXCSR); + struct musb_hw_ep *hw_ep = &musb->endpoints[epnum]; + + if (hw_ep->is_shared_fifo) + musb_ep = &hw_ep->ep_in; + else + musb_ep = &hw_ep->ep_out; + + len = musb_ep->packet_sz; /* We shouldn't get here while DMA is active, but we do... */ if (dma_channel_status(musb_ep->dma) == MUSB_DMA_STATUS_BUSY) { @@ -740,9 +748,15 @@ void musb_g_rx(struct musb *musb, u8 epnum) u16 csr; struct usb_request *request; void __iomem *mbase = musb->mregs; - struct musb_ep *musb_ep = &musb->endpoints[epnum].ep_out; + struct musb_ep *musb_ep; void __iomem *epio = musb->endpoints[epnum].regs; struct dma_channel *dma; + struct musb_hw_ep *hw_ep = &musb->endpoints[epnum]; + + if (hw_ep->is_shared_fifo) + musb_ep = &hw_ep->ep_in; + else + musb_ep = &hw_ep->ep_out; musb_ep_select(mbase, epnum);