195-USB-bcma-make-helper-creating-platform-dev-more-gene.patch 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. Having "bool ohci" argument bounded us to two cases only and didn't
  10. allow re-using this code for XHCI.
  11. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
  12. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
  13. ---
  14. drivers/usb/host/bcma-hcd.c | 24 +++++++++++++-----------
  15. 1 file changed, 13 insertions(+), 11 deletions(-)
  16. --- a/drivers/usb/host/bcma-hcd.c
  17. +++ b/drivers/usb/host/bcma-hcd.c
  18. @@ -244,7 +244,10 @@ static const struct usb_ehci_pdata ehci_
  19. static const struct usb_ohci_pdata ohci_pdata = {
  20. };
  21. -static struct platform_device *bcma_hcd_create_pdev(struct bcma_device *dev, bool ohci, u32 addr)
  22. +static struct platform_device *bcma_hcd_create_pdev(struct bcma_device *dev,
  23. + const char *name, u32 addr,
  24. + const void *data,
  25. + size_t size)
  26. {
  27. struct platform_device *hci_dev;
  28. struct resource hci_res[2];
  29. @@ -259,8 +262,7 @@ static struct platform_device *bcma_hcd_
  30. hci_res[1].start = dev->irq;
  31. hci_res[1].flags = IORESOURCE_IRQ;
  32. - hci_dev = platform_device_alloc(ohci ? "ohci-platform" :
  33. - "ehci-platform" , 0);
  34. + hci_dev = platform_device_alloc(name, 0);
  35. if (!hci_dev)
  36. return ERR_PTR(-ENOMEM);
  37. @@ -271,12 +273,8 @@ static struct platform_device *bcma_hcd_
  38. ARRAY_SIZE(hci_res));
  39. if (ret)
  40. goto err_alloc;
  41. - if (ohci)
  42. - ret = platform_device_add_data(hci_dev, &ohci_pdata,
  43. - sizeof(ohci_pdata));
  44. - else
  45. - ret = platform_device_add_data(hci_dev, &ehci_pdata,
  46. - sizeof(ehci_pdata));
  47. + if (data)
  48. + ret = platform_device_add_data(hci_dev, data, size);
  49. if (ret)
  50. goto err_alloc;
  51. ret = platform_device_add(hci_dev);
  52. @@ -333,11 +331,15 @@ static int bcma_hcd_probe(struct bcma_de
  53. && chipinfo->rev == 0)
  54. ohci_addr = 0x18009000;
  55. - usb_dev->ohci_dev = bcma_hcd_create_pdev(dev, true, ohci_addr);
  56. + usb_dev->ohci_dev = bcma_hcd_create_pdev(dev, "ohci-platform",
  57. + ohci_addr, &ohci_pdata,
  58. + sizeof(ohci_pdata));
  59. if (IS_ERR(usb_dev->ohci_dev))
  60. return PTR_ERR(usb_dev->ohci_dev);
  61. - usb_dev->ehci_dev = bcma_hcd_create_pdev(dev, false, dev->addr);
  62. + usb_dev->ehci_dev = bcma_hcd_create_pdev(dev, "ehci-platform",
  63. + dev->addr, &ehci_pdata,
  64. + sizeof(ehci_pdata));
  65. if (IS_ERR(usb_dev->ehci_dev)) {
  66. err = PTR_ERR(usb_dev->ehci_dev);
  67. goto err_unregister_ohci_dev;