From: Jean-Christophe PLAGNIOL-VILLARD Date: Mon, 20 May 2013 14:46:02 +0000 (+0800) Subject: USB: gadget: atmel_usba: allow multi instance X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=e8f2ea39327a1f76aa9f0c606812eb0b154b8e45;p=linux-beck.git USB: gadget: atmel_usba: allow multi instance drop static struct usba_udc the_udc Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Acked-by: Felipe Balbi Acked-by: Nicolas Ferre Tested-by: Bo Shen --- diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c index d2ffd0438a6b..eea57a3ca778 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;