320b6dd31dd0fc41a7426fc56a26fb1609adc2fe
[oweals/openwrt.git] /
1 From 352d9e2ee85b43170388599a17cd7b219f270163 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
3 Date: Sat, 5 Dec 2015 13:15:06 +0100
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 in bcma_hcd_create_pdev function limited it
10 to support two cases only (OHCI and EHCI) and put too much logic in it.
11 Lets make caller pass all required data. This adds few extra arguments
12 to the function call but will allow us to reuse this code and handle
13 more cases in the future (e.g. add XHCI support).
14
15 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
16 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
17 ---
18  drivers/usb/host/bcma-hcd.c | 24 +++++++++++++-----------
19  1 file changed, 13 insertions(+), 11 deletions(-)
20
21 --- a/drivers/usb/host/bcma-hcd.c
22 +++ b/drivers/usb/host/bcma-hcd.c
23 @@ -244,7 +244,10 @@ static const struct usb_ehci_pdata ehci_
24  static const struct usb_ohci_pdata ohci_pdata = {
25  };
26  
27 -static struct platform_device *bcma_hcd_create_pdev(struct bcma_device *dev, bool ohci, u32 addr)
28 +static struct platform_device *bcma_hcd_create_pdev(struct bcma_device *dev,
29 +                                                   const char *name, u32 addr,
30 +                                                   const void *data,
31 +                                                   size_t size)
32  {
33         struct platform_device *hci_dev;
34         struct resource hci_res[2];
35 @@ -259,8 +262,7 @@ static struct platform_device *bcma_hcd_
36         hci_res[1].start = dev->irq;
37         hci_res[1].flags = IORESOURCE_IRQ;
38  
39 -       hci_dev = platform_device_alloc(ohci ? "ohci-platform" :
40 -                                       "ehci-platform" , 0);
41 +       hci_dev = platform_device_alloc(name, 0);
42         if (!hci_dev)
43                 return ERR_PTR(-ENOMEM);
44  
45 @@ -271,12 +273,8 @@ static struct platform_device *bcma_hcd_
46                                             ARRAY_SIZE(hci_res));
47         if (ret)
48                 goto err_alloc;
49 -       if (ohci)
50 -               ret = platform_device_add_data(hci_dev, &ohci_pdata,
51 -                                              sizeof(ohci_pdata));
52 -       else
53 -               ret = platform_device_add_data(hci_dev, &ehci_pdata,
54 -                                              sizeof(ehci_pdata));
55 +       if (data)
56 +               ret = platform_device_add_data(hci_dev, data, size);
57         if (ret)
58                 goto err_alloc;
59         ret = platform_device_add(hci_dev);
60 @@ -333,11 +331,15 @@ static int bcma_hcd_probe(struct bcma_de
61             && chipinfo->rev == 0)
62                 ohci_addr = 0x18009000;
63  
64 -       usb_dev->ohci_dev = bcma_hcd_create_pdev(dev, true, ohci_addr);
65 +       usb_dev->ohci_dev = bcma_hcd_create_pdev(dev, "ohci-platform",
66 +                                                ohci_addr, &ohci_pdata,
67 +                                                sizeof(ohci_pdata));
68         if (IS_ERR(usb_dev->ohci_dev))
69                 return PTR_ERR(usb_dev->ohci_dev);
70  
71 -       usb_dev->ehci_dev = bcma_hcd_create_pdev(dev, false, dev->addr);
72 +       usb_dev->ehci_dev = bcma_hcd_create_pdev(dev, "ehci-platform",
73 +                                                dev->addr, &ehci_pdata,
74 +                                                sizeof(ehci_pdata));
75         if (IS_ERR(usb_dev->ehci_dev)) {
76                 err = PTR_ERR(usb_dev->ehci_dev);
77                 goto err_unregister_ohci_dev;