From patchwork Mon May 20 16:25:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Christophe PLAGNIOL-VILLARD X-Patchwork-Id: 2594261 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork1.kernel.org (Postfix) with ESMTP id 175803FE81 for ; Mon, 20 May 2013 16:44:22 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UeT81-0005t5-71; Mon, 20 May 2013 16:40:06 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UeT7b-00059D-Np; Mon, 20 May 2013 16:39:39 +0000 Received: from 13.mo1.mail-out.ovh.net ([178.33.253.128] helo=mo1.mail-out.ovh.net) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UeSyp-0004tR-Gu for linux-arm-kernel@lists.infradead.org; Mon, 20 May 2013 16:30:37 +0000 Received: from mail194.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo1.mail-out.ovh.net (Postfix) with SMTP id 939F9FF8C1B for ; Mon, 20 May 2013 18:30:15 +0200 (CEST) Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 20 May 2013 18:30:15 +0200 Received: from ns32433.ovh.net (HELO localhost) (plagnioj%jcrosoft.com@213.251.161.87) by ns0.ovh.net with SMTP; 20 May 2013 18:30:14 +0200 From: Jean-Christophe PLAGNIOL-VILLARD To: linux-arm-kernel@lists.infradead.org X-Ovh-Mailout: 178.32.228.1 (mo1.mail-out.ovh.net) Subject: [PATCH 2/7] USB: gadget: atmel_usba: allow multi instance Date: Mon, 20 May 2013 18:25:55 +0200 Message-Id: <1369067160-3230-2-git-send-email-plagnioj@jcrosoft.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1369067160-3230-1-git-send-email-plagnioj@jcrosoft.com> References: <20130520162149.GC9937@game.jcrosoft.org> <1369067160-3230-1-git-send-email-plagnioj@jcrosoft.com> X-Ovh-Tracer-Id: 5734771175736781821 X-Ovh-Remote: 213.251.161.87 (ns32433.ovh.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-OVH-SPAMSTATE: OK X-OVH-SPAMSCORE: -100 X-OVH-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeeifedrleefucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-Spam-Check: DONE|U 0.5/N X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeeifedrleefucetufdoteggodetrfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130520_123035_748549_D961DE72 X-CRM114-Status: GOOD ( 14.78 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [178.33.253.128 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Nicolas Ferre , devicetree-discuss@lists.ozlabs.org, linux-usb@vger.kernel.org, Jean-Christophe PLAGNIOL-VILLARD X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org drop static struct usba_udc the_udc Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Cc: Nicolas Ferre Cc: linux-usb@vger.kernel.org Acked-by: Felipe Balbi --- drivers/usb/gadget/atmel_usba_udc.c | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c index d2ffd04..eea57a3 100644 --- a/drivers/usb/gadget/atmel_usba_udc.c +++ b/drivers/usb/gadget/atmel_usba_udc.c @@ -27,9 +27,6 @@ #include "atmel_usba_udc.h" - -static struct usba_udc the_udc; - #ifdef CONFIG_USB_GADGET_DEBUG_FS #include #include @@ -1013,16 +1010,13 @@ static void nop_release(struct device *dev) } -static struct usba_udc the_udc = { - .gadget = { - .ops = &usba_udc_ops, - .ep_list = LIST_HEAD_INIT(the_udc.gadget.ep_list), - .max_speed = USB_SPEED_HIGH, - .name = "atmel_usba_udc", - .dev = { - .init_name = "gadget", - .release = nop_release, - }, +struct usb_gadget usba_gadget_template = { + .ops = &usba_udc_ops, + .max_speed = USB_SPEED_HIGH, + .name = "atmel_usba_udc", + .dev = { + .init_name = "gadget", + .release = nop_release, }, }; @@ -1839,10 +1833,17 @@ static int __init usba_udc_probe(struct platform_device *pdev) struct usba_platform_data *pdata = pdev->dev.platform_data; struct resource *regs, *fifo; struct clk *pclk, *hclk; - struct usba_udc *udc = &the_udc; + struct usba_udc *udc; static struct usba_ep *usba_ep; int irq, ret, i; + udc = devm_kzalloc(&pdev->dev, sizeof(*udc), GFP_KERNEL); + if (!udc) + return -ENOMEM; + + udc->gadget = usba_gadget_template; + INIT_LIST_HEAD(&udc->gadget.ep_list); + regs = platform_get_resource(pdev, IORESOURCE_MEM, CTRL_IOMEM_ID); fifo = platform_get_resource(pdev, IORESOURCE_MEM, FIFO_IOMEM_ID); if (!regs || !fifo || !pdata) @@ -1897,8 +1898,7 @@ static int __init usba_udc_probe(struct platform_device *pdev) goto err_alloc_ep; udc->usba_ep = usba_ep; - - the_udc.gadget.ep0 = &usba_ep[0].ep; + udc->gadget.ep0 = &usba_ep[0].ep; INIT_LIST_HEAD(&usba_ep[0].ep.ep_list); usba_ep[0].ep_regs = udc->regs + USBA_EPT_BASE(0); @@ -1907,7 +1907,7 @@ static int __init usba_udc_probe(struct platform_device *pdev) usba_ep[0].ep.ops = &usba_ep_ops; usba_ep[0].ep.name = pdata->ep[0].name; usba_ep[0].ep.maxpacket = pdata->ep[0].fifo_size; - usba_ep[0].udc = &the_udc; + usba_ep[0].udc = udc; INIT_LIST_HEAD(&usba_ep[0].queue); usba_ep[0].fifo_size = pdata->ep[0].fifo_size; usba_ep[0].nr_banks = pdata->ep[0].nr_banks; @@ -1924,7 +1924,7 @@ static int __init usba_udc_probe(struct platform_device *pdev) ep->ep.ops = &usba_ep_ops; ep->ep.name = pdata->ep[i].name; ep->ep.maxpacket = pdata->ep[i].fifo_size; - ep->udc = &the_udc; + ep->udc = udc; INIT_LIST_HEAD(&ep->queue); ep->fifo_size = pdata->ep[i].fifo_size; ep->nr_banks = pdata->ep[i].nr_banks;