084-01-USB-bcma-make-helper-creating-platform-dev-more-gene.patch 2.8 KB

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