From patchwork Thu Sep 3 16:57:09 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 45399 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 n83GvFbY013443 for ; Thu, 3 Sep 2009 16:57:15 GMT Received: from dlep35.itg.ti.com ([157.170.170.118]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id n83GtRkT020162; Thu, 3 Sep 2009 11:55:33 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep35.itg.ti.com (8.13.7/8.13.7) with ESMTP id n83GtQxi016051; Thu, 3 Sep 2009 11:55:27 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 5188A80627; Thu, 3 Sep 2009 11:55:26 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp53.itg.ti.com (dflp53.itg.ti.com [128.247.5.6]) by linux.omap.com (Postfix) with ESMTP id 139EC80626 for ; Thu, 3 Sep 2009 11:55:25 -0500 (CDT) Received: from white.ext.ti.com (localhost [127.0.0.1]) by dflp53.itg.ti.com (8.13.8/8.13.8) with ESMTP id n83GtOv6017664 for ; Thu, 3 Sep 2009 11:55:24 -0500 (CDT) Received: from mail82-tx2-R.bigfish.com (mail-tx2.bigfish.com [65.55.88.112]) by white.ext.ti.com (8.13.7/8.13.7) with ESMTP id n83GtJGt018682 for ; Thu, 3 Sep 2009 11:55:24 -0500 Received: from mail82-tx2 (localhost.localdomain [127.0.0.1]) by mail82-tx2-R.bigfish.com (Postfix) with ESMTP id 76F82A284A3 for ; Thu, 3 Sep 2009 16:55:19 +0000 (UTC) X-SpamScore: -5 X-BigFish: vps-5(zz936eMzz1202hzzz2dh6bh63h) X-Spam-TCS-SCL: 2:0 X-FB-SS: 5, X-MS-Exchange-Organization-Antispam-Report: OrigIP: 63.81.120.155; Service: EHS Received: by mail82-tx2 (MessageSwitch) id 1251996917477094_26824; Thu, 3 Sep 2009 16:55:17 +0000 (UCT) Received: from imap.sh.mvista.com (unknown [63.81.120.155]) by mail82-tx2.bigfish.com (Postfix) with ESMTP id 3825B910053 for ; Thu, 3 Sep 2009 16:55:17 +0000 (UTC) Received: from wasted.dev.rtsoft.ru (unknown [10.150.0.9]) by imap.sh.mvista.com (Postfix) with ESMTP id DF2493EC9; Thu, 3 Sep 2009 09:55:14 -0700 (PDT) From: Sergei Shtylyov Organization: MontaVista Software Inc. To: gregkh@suse.de, david-b@pacbell.net Date: Thu, 3 Sep 2009 19:57:09 +0300 User-Agent: KMail/1.5 MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200909032057.09356.sshtylyov@ru.mvista.com> Cc: davinci-linux-open-source@linux.davincidsp.com, linux-usb@vger.kernel.org Subject: [PATCH 2/4] musb_gadget: implement set_wedge() method 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 Implement the driver's set_wedge() method by adding the 'wedged' flag to the 'struct musb_ep'. 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.c | 21 +++++++++++++++++++-- drivers/usb/musb/musb_gadget.h | 2 ++ drivers/usb/musb/musb_gadget_ep0.c | 6 +++++- 3 files changed, 26 insertions(+), 3 deletions(-) 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 */