kernel: backport more 4.6 bcma stuff needed for new chipsets
[openwrt/openwrt.git] / target / linux / bcm53xx / patches-4.4 / 195-USB-bcma-make-helper-creating-platform-dev-more-gene.patch
1 From c7c7bf7fcbacadac7781783de25fe1e13e2a2c35 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 v3 3/6] usb: bcma: make helper creating platform dev more
5 generic
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 Having "bool ohci" argument bounded us to two cases only and didn't
11 allow re-using this code for XHCI.
12
13 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
14 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
15 ---
16 drivers/usb/host/bcma-hcd.c | 24 +++++++++++++-----------
17 1 file changed, 13 insertions(+), 11 deletions(-)
18
19 --- a/drivers/usb/host/bcma-hcd.c
20 +++ b/drivers/usb/host/bcma-hcd.c
21 @@ -244,7 +244,10 @@ static const struct usb_ehci_pdata ehci_
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 @@ -259,8 +262,7 @@ static struct platform_device *bcma_hcd_
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 @@ -271,12 +273,8 @@ static struct platform_device *bcma_hcd_
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 @@ -333,11 +331,15 @@ static int bcma_hcd_probe(struct bcma_de
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;