From patchwork Wed Nov 18 19:51:51 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 61169 Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nAIJrCCq026656 for ; Wed, 18 Nov 2009 19:53:12 GMT Received: from dlep36.itg.ti.com ([157.170.170.91]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id nAIJpcQg003607 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 18 Nov 2009 13:51:47 -0600 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep36.itg.ti.com (8.13.8/8.13.8) with ESMTP id nAIJpb4u000136; Wed, 18 Nov 2009 13:51:37 -0600 (CST) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 933ED80627; Wed, 18 Nov 2009 13:51:37 -0600 (CST) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp51.itg.ti.com (dflp51.itg.ti.com [128.247.22.94]) by linux.omap.com (Postfix) with ESMTP id C4F4480626 for ; Wed, 18 Nov 2009 13:51:34 -0600 (CST) Received: from medina.ext.ti.com (localhost [127.0.0.1]) by dflp51.itg.ti.com (8.13.7/8.13.7) with ESMTP id nAIJpYYM007638 for ; Wed, 18 Nov 2009 13:51:34 -0600 (CST) Received: from mail63-tx2-R.bigfish.com (mail-tx2.bigfish.com [65.55.88.112]) by medina.ext.ti.com (8.13.7/8.13.7) with ESMTP id nAIJpYBE028604 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Wed, 18 Nov 2009 13:51:34 -0600 Received: from mail63-tx2 (localhost.localdomain [127.0.0.1]) by mail63-tx2-R.bigfish.com (Postfix) with ESMTP id 2317A16703B1 for ; Wed, 18 Nov 2009 19:51:34 +0000 (UTC) X-SpamScore: 4 X-BigFish: vps4(zz936eMzz1202hzzz2dh6bh259o43j61h) X-Spam-TCS-SCL: 0:0 X-MS-Exchange-Organization-Antispam-Report: OrigIP: 206.112.117.35; Service: EHS Received: from mail63-tx2 (localhost.localdomain [127.0.0.1]) by mail63-tx2 (MessageSwitch) id 1258573882314595_20650; Wed, 18 Nov 2009 19:51:22 +0000 (UTC) Received: from TX2EHSMHS001.bigfish.com (unknown [10.9.14.244]) by mail63-tx2.bigfish.com (Postfix) with ESMTP id 347281090051 for ; Wed, 18 Nov 2009 19:51:22 +0000 (UTC) Received: from imap.sh.mvista.com (206.112.117.35) by TX2EHSMHS001.bigfish.com (10.9.99.101) with Microsoft SMTP Server id 14.0.482.32; Wed, 18 Nov 2009 19:51:19 +0000 Received: from wasted.dev.rtsoft.ru (unknown [10.150.0.9]) by imap.sh.mvista.com (Postfix) with SMTP id D25BE3ED8; Wed, 18 Nov 2009 11:51:15 -0800 (PST) From: Sergei Shtylyov Organization: MontaVista Software Inc. To: gregkh@suse.de, david-b@pacbell.net Subject: [PATCH 2/4] musb_gadget: implement set_wedge() method Date: Wed, 18 Nov 2009 22:51:51 +0300 User-Agent: KMail/1.5 MIME-Version: 1.0 Content-Disposition: inline Message-ID: <200911182251.51894.sshtylyov@ru.mvista.com> X-Reverse-DNS: unknown Cc: davinci-linux-open-source@linux.davincidsp.com, linux-usb@vger.kernel.org X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: 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 Index: linux-2.6/drivers/usb/musb/musb_gadget.c =================================================================== --- linux-2.6.orig/drivers/usb/musb/musb_gadget.c +++ linux-2.6/drivers/usb/musb/musb_gadget.c @@ -965,7 +965,7 @@ static int musb_gadget_enable(struct usb musb_ep->dma = NULL; musb_ep->desc = desc; - musb_ep->busy = 0; + musb_ep->wedged = musb_ep->busy = 0; status = 0; pr_debug("%s periph: enabled %s for %s %s, %smaxpacket %d\n", @@ -1262,7 +1262,8 @@ int musb_gadget_set_halt(struct usb_ep * goto done; } } - } + } else + musb_ep->wedged = 0; /* set/clear the stall and toggle bits */ DBG(2, "%s: %s stall\n", ep->name, value ? "set" : "clear"); @@ -1301,6 +1302,21 @@ done: return status; } +/* + * Sets the halt feature with the clear requests ignored + */ +int musb_gadget_set_wedge(struct usb_ep *ep) +{ + struct musb_ep *musb_ep = to_musb_ep(ep); + + if (!ep) + return -EINVAL; + + musb_ep->wedged = 1; + + return usb_ep_set_halt(ep); +} + static int musb_gadget_fifo_status(struct usb_ep *ep) { struct musb_ep *musb_ep = to_musb_ep(ep); @@ -1371,6 +1387,7 @@ static const struct usb_ep_ops musb_ep_o .queue = musb_gadget_queue, .dequeue = musb_gadget_dequeue, .set_halt = musb_gadget_set_halt, + .set_wedge = musb_gadget_set_wedge, .fifo_status = musb_gadget_fifo_status, .fifo_flush = musb_gadget_fifo_flush }; 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 @@ -75,6 +75,8 @@ struct musb_ep { /* later things are modified based on usage */ struct list_head req_list; + u8 wedged; + /* true if lock must be dropped but req_list may not be advanced */ u8 busy; }; 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 @@ -273,6 +273,11 @@ __acquires(musb->lock) if (!musb_ep->desc) break; + handled = 1; + /* Ignore request if endpoint is wedged */ + 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); @@ -280,7 +285,6 @@ __acquires(musb->lock) /* select ep0 again */ musb_ep_select(mbase, 0); - handled = 1; } break; default: /* class, vendor, etc ... delegate */