diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2013-05-20 10:46:02 -0400 |
---|---|---|
committer | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2013-05-23 19:14:16 -0400 |
commit | e8f2ea39327a1f76aa9f0c606812eb0b154b8e45 (patch) | |
tree | d05e09a6851247ac43f2bb432e1534e72d876849 /drivers/usb/gadget/atmel_usba_udc.c | |
parent | 68522de70e4b08445c10cded43c08b016ebda538 (diff) |
USB: gadget: atmel_usba: allow multi instance
drop static struct usba_udc the_udc
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Acked-by: Felipe Balbi <balbi@ti.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Tested-by: Bo Shen <voice.shen@atmel.com>
Diffstat (limited to 'drivers/usb/gadget/atmel_usba_udc.c')
-rw-r--r-- | drivers/usb/gadget/atmel_usba_udc.c | 36 |
1 files changed, 18 insertions, 18 deletions
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 @@ | |||
27 | 27 | ||
28 | #include "atmel_usba_udc.h" | 28 | #include "atmel_usba_udc.h" |
29 | 29 | ||
30 | |||
31 | static struct usba_udc the_udc; | ||
32 | |||
33 | #ifdef CONFIG_USB_GADGET_DEBUG_FS | 30 | #ifdef CONFIG_USB_GADGET_DEBUG_FS |
34 | #include <linux/debugfs.h> | 31 | #include <linux/debugfs.h> |
35 | #include <linux/uaccess.h> | 32 | #include <linux/uaccess.h> |
@@ -1013,16 +1010,13 @@ static void nop_release(struct device *dev) | |||
1013 | 1010 | ||
1014 | } | 1011 | } |
1015 | 1012 | ||
1016 | static struct usba_udc the_udc = { | 1013 | struct usb_gadget usba_gadget_template = { |
1017 | .gadget = { | 1014 | .ops = &usba_udc_ops, |
1018 | .ops = &usba_udc_ops, | 1015 | .max_speed = USB_SPEED_HIGH, |
1019 | .ep_list = LIST_HEAD_INIT(the_udc.gadget.ep_list), | 1016 | .name = "atmel_usba_udc", |
1020 | .max_speed = USB_SPEED_HIGH, | 1017 | .dev = { |
1021 | .name = "atmel_usba_udc", | 1018 | .init_name = "gadget", |
1022 | .dev = { | 1019 | .release = nop_release, |
1023 | .init_name = "gadget", | ||
1024 | .release = nop_release, | ||
1025 | }, | ||
1026 | }, | 1020 | }, |
1027 | }; | 1021 | }; |
1028 | 1022 | ||
@@ -1839,10 +1833,17 @@ static int __init usba_udc_probe(struct platform_device *pdev) | |||
1839 | struct usba_platform_data *pdata = pdev->dev.platform_data; | 1833 | struct usba_platform_data *pdata = pdev->dev.platform_data; |
1840 | struct resource *regs, *fifo; | 1834 | struct resource *regs, *fifo; |
1841 | struct clk *pclk, *hclk; | 1835 | struct clk *pclk, *hclk; |
1842 | struct usba_udc *udc = &the_udc; | 1836 | struct usba_udc *udc; |
1843 | static struct usba_ep *usba_ep; | 1837 | static struct usba_ep *usba_ep; |
1844 | int irq, ret, i; | 1838 | int irq, ret, i; |
1845 | 1839 | ||
1840 | udc = devm_kzalloc(&pdev->dev, sizeof(*udc), GFP_KERNEL); | ||
1841 | if (!udc) | ||
1842 | return -ENOMEM; | ||
1843 | |||
1844 | udc->gadget = usba_gadget_template; | ||
1845 | INIT_LIST_HEAD(&udc->gadget.ep_list); | ||
1846 | |||
1846 | regs = platform_get_resource(pdev, IORESOURCE_MEM, CTRL_IOMEM_ID); | 1847 | regs = platform_get_resource(pdev, IORESOURCE_MEM, CTRL_IOMEM_ID); |
1847 | fifo = platform_get_resource(pdev, IORESOURCE_MEM, FIFO_IOMEM_ID); | 1848 | fifo = platform_get_resource(pdev, IORESOURCE_MEM, FIFO_IOMEM_ID); |
1848 | if (!regs || !fifo || !pdata) | 1849 | if (!regs || !fifo || !pdata) |
@@ -1897,8 +1898,7 @@ static int __init usba_udc_probe(struct platform_device *pdev) | |||
1897 | goto err_alloc_ep; | 1898 | goto err_alloc_ep; |
1898 | 1899 | ||
1899 | udc->usba_ep = usba_ep; | 1900 | udc->usba_ep = usba_ep; |
1900 | 1901 | udc->gadget.ep0 = &usba_ep[0].ep; | |
1901 | the_udc.gadget.ep0 = &usba_ep[0].ep; | ||
1902 | 1902 | ||
1903 | INIT_LIST_HEAD(&usba_ep[0].ep.ep_list); | 1903 | INIT_LIST_HEAD(&usba_ep[0].ep.ep_list); |
1904 | usba_ep[0].ep_regs = udc->regs + USBA_EPT_BASE(0); | 1904 | 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) | |||
1907 | usba_ep[0].ep.ops = &usba_ep_ops; | 1907 | usba_ep[0].ep.ops = &usba_ep_ops; |
1908 | usba_ep[0].ep.name = pdata->ep[0].name; | 1908 | usba_ep[0].ep.name = pdata->ep[0].name; |
1909 | usba_ep[0].ep.maxpacket = pdata->ep[0].fifo_size; | 1909 | usba_ep[0].ep.maxpacket = pdata->ep[0].fifo_size; |
1910 | usba_ep[0].udc = &the_udc; | 1910 | usba_ep[0].udc = udc; |
1911 | INIT_LIST_HEAD(&usba_ep[0].queue); | 1911 | INIT_LIST_HEAD(&usba_ep[0].queue); |
1912 | usba_ep[0].fifo_size = pdata->ep[0].fifo_size; | 1912 | usba_ep[0].fifo_size = pdata->ep[0].fifo_size; |
1913 | usba_ep[0].nr_banks = pdata->ep[0].nr_banks; | 1913 | usba_ep[0].nr_banks = pdata->ep[0].nr_banks; |
@@ -1924,7 +1924,7 @@ static int __init usba_udc_probe(struct platform_device *pdev) | |||
1924 | ep->ep.ops = &usba_ep_ops; | 1924 | ep->ep.ops = &usba_ep_ops; |
1925 | ep->ep.name = pdata->ep[i].name; | 1925 | ep->ep.name = pdata->ep[i].name; |
1926 | ep->ep.maxpacket = pdata->ep[i].fifo_size; | 1926 | ep->ep.maxpacket = pdata->ep[i].fifo_size; |
1927 | ep->udc = &the_udc; | 1927 | ep->udc = udc; |
1928 | INIT_LIST_HEAD(&ep->queue); | 1928 | INIT_LIST_HEAD(&ep->queue); |
1929 | ep->fifo_size = pdata->ep[i].fifo_size; | 1929 | ep->fifo_size = pdata->ep[i].fifo_size; |
1930 | ep->nr_banks = pdata->ep[i].nr_banks; | 1930 | ep->nr_banks = pdata->ep[i].nr_banks; |