bcm53xx: add xHCI support
[openwrt.git] / target / linux / bcm53xx / patches-3.18 / 810-USB-bcma-make-helper-creating-platform-dev-more-gene.patch
1 From 5b4fed9fc917cc2bfc5297eeab03aeba5d340618 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
3 Date: Tue, 16 Jun 2015 12:33:46 +0200
4 Subject: [PATCH] USB: bcma: make helper creating platform dev more generic
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Having "bool ohci" argument bounded us to two cases only and didn't
10 allow re-using this code for XHCI.
11
12 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
13 ---
14  drivers/usb/host/bcma-hcd.c | 24 +++++++++++++-----------
15  1 file changed, 13 insertions(+), 11 deletions(-)
16
17 diff --git a/drivers/usb/host/bcma-hcd.c b/drivers/usb/host/bcma-hcd.c
18 index 5398e3d..d347282 100644
19 --- a/drivers/usb/host/bcma-hcd.c
20 +++ b/drivers/usb/host/bcma-hcd.c
21 @@ -249,7 +249,10 @@ static const struct usb_ehci_pdata ehci_pdata = {
22  static const struct usb_ohci_pdata ohci_pdata = {
23  };
24  
25 -static struct platform_device *bcma_hcd_create_pdev(struct bcma_device *dev, bool ohci, u32 addr)
26 +static struct platform_device *bcma_hcd_create_pdev(struct bcma_device *dev,
27 +                                                   const char *name, u32 addr,
28 +                                                   const void *data,
29 +                                                   size_t size)
30  {
31         struct platform_device *hci_dev;
32         struct resource hci_res[2];
33 @@ -264,8 +267,7 @@ static struct platform_device *bcma_hcd_create_pdev(struct bcma_device *dev, boo
34         hci_res[1].start = dev->irq;
35         hci_res[1].flags = IORESOURCE_IRQ;
36  
37 -       hci_dev = platform_device_alloc(ohci ? "ohci-platform" :
38 -                                       "ehci-platform" , 0);
39 +       hci_dev = platform_device_alloc(name, 0);
40         if (!hci_dev)
41                 return ERR_PTR(-ENOMEM);
42  
43 @@ -276,12 +278,8 @@ static struct platform_device *bcma_hcd_create_pdev(struct bcma_device *dev, boo
44                                             ARRAY_SIZE(hci_res));
45         if (ret)
46                 goto err_alloc;
47 -       if (ohci)
48 -               ret = platform_device_add_data(hci_dev, &ohci_pdata,
49 -                                              sizeof(ohci_pdata));
50 -       else
51 -               ret = platform_device_add_data(hci_dev, &ehci_pdata,
52 -                                              sizeof(ehci_pdata));
53 +       if (data)
54 +               ret = platform_device_add_data(hci_dev, data, size);
55         if (ret)
56                 goto err_alloc;
57         ret = platform_device_add(hci_dev);
58 @@ -334,11 +332,15 @@ static int bcma_hcd_probe(struct bcma_device *dev)
59             && chipinfo->rev == 0)
60                 ohci_addr = 0x18009000;
61  
62 -       usb_dev->ohci_dev = bcma_hcd_create_pdev(dev, true, ohci_addr);
63 +       usb_dev->ohci_dev = bcma_hcd_create_pdev(dev, "ohci-platform",
64 +                                                ohci_addr, &ohci_pdata,
65 +                                                sizeof(ohci_pdata));
66         if (IS_ERR(usb_dev->ohci_dev))
67                 return PTR_ERR(usb_dev->ohci_dev);
68  
69 -       usb_dev->ehci_dev = bcma_hcd_create_pdev(dev, false, dev->addr);
70 +       usb_dev->ehci_dev = bcma_hcd_create_pdev(dev, "ehci-platform",
71 +                                                dev->addr, &ehci_pdata,
72 +                                                sizeof(ehci_pdata));
73         if (IS_ERR(usb_dev->ehci_dev)) {
74                 err = PTR_ERR(usb_dev->ehci_dev);
75                 goto err_unregister_ohci_dev;
76 -- 
77 1.8.4.5
78