USB: OHCI: make ohci-platform a separate driver
authorManjunath Goudar <manjunath.goudar@linaro.org>
Mon, 3 Jun 2013 15:16:08 +0000 (20:46 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 3 Jun 2013 18:02:26 +0000 (11:02 -0700)
This patch splits the ohci-platform code from ohci-hcd out
into its own separate driver module.This work is part of enabling
multi-platform kernels on ARM.

In V2:
  -Passed "hcd" argument instead of "ohci" in ohci_setup() because it is
   using "struct usb_hcd" argument.
In V3:
  -Directly passed "hcd" argument not required to call ohci_to_hcd() function.

Signed-off-by: Manjunath Goudar <manjunath.goudar@linaro.org>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/Kconfig
drivers/usb/host/Makefile
drivers/usb/host/ohci-hcd.c
drivers/usb/host/ohci-platform.c

index 972ddd39c1de6cd5afec501cffaa83e76fc3406f..d61a026b9248811bc97e18f9e6b11d63d439ac94 100644 (file)
@@ -481,7 +481,7 @@ config USB_CNS3XXX_OHCI
          It is needed for low-speed USB 1.0 device support.
 
 config USB_OHCI_HCD_PLATFORM
-       bool "Generic OHCI driver for a platform device"
+       tristate "Generic OHCI driver for a platform device"
        default n
        ---help---
          Adds an OHCI host driver for a generic platform device, which
index dbc785d6b4a1847920c988de4b8b65b60b7b68b9..b41fa5f9c2790d4c77e172351605548836173f5f 100644 (file)
@@ -40,6 +40,7 @@ obj-$(CONFIG_USB_ISP1362_HCD) += isp1362-hcd.o
 
 obj-$(CONFIG_USB_OHCI_HCD)     += ohci-hcd.o
 obj-$(CONFIG_USB_OHCI_HCD_PCI) += ohci-pci.o
+obj-$(CONFIG_USB_OHCI_HCD_PLATFORM)    += ohci-platform.o
 
 obj-$(CONFIG_USB_UHCI_HCD)     += uhci-hcd.o
 obj-$(CONFIG_USB_FHCI_HCD)     += fhci.o
index 52959a1f07084afdf2506b74199380e538b2652b..4847ee971db96a1c0ef03edb8b9644d440d40588 100644 (file)
@@ -1262,12 +1262,8 @@ MODULE_LICENSE ("GPL");
 #define PLATFORM_DRIVER                ohci_hcd_tilegx_driver
 #endif
 
-#ifdef CONFIG_USB_OHCI_HCD_PLATFORM
-#include "ohci-platform.c"
-#define PLATFORM_DRIVER                ohci_platform_driver
-#endif
-
 #if    !IS_ENABLED(CONFIG_USB_OHCI_HCD_PCI) && \
+       !IS_ENABLED(CONFIG_USB_OHCI_HCD_PLATFORM) && \
        !defined(PLATFORM_DRIVER) &&    \
        !defined(OMAP1_PLATFORM_DRIVER) &&      \
        !defined(OMAP3_PLATFORM_DRIVER) &&      \
index 76a3531bf9d1098f6fcf588474fd6ef3bf405e00..bc30475c3a236886e3784d47ccfdaa4fbd5b7fb3 100644 (file)
  *
  * Licensed under the GNU/GPL. See COPYING for details.
  */
+
+#include <linux/hrtimer.h>
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
 #include <linux/err.h>
 #include <linux/platform_device.h>
 #include <linux/usb/ohci_pdriver.h>
+#include <linux/usb.h>
+#include <linux/usb/hcd.h>
+
+#include "ohci.h"
+
+#define DRIVER_DESC "OHCI generic platform driver"
+
+static const char hcd_name[] = "ohci-platform";
 
 static int ohci_platform_reset(struct usb_hcd *hcd)
 {
        struct platform_device *pdev = to_platform_device(hcd->self.controller);
        struct usb_ohci_pdata *pdata = pdev->dev.platform_data;
        struct ohci_hcd *ohci = hcd_to_ohci(hcd);
-       int err;
 
        if (pdata->big_endian_desc)
                ohci->flags |= OHCI_QUIRK_BE_DESC;
@@ -30,58 +42,17 @@ static int ohci_platform_reset(struct usb_hcd *hcd)
                ohci->flags |= OHCI_QUIRK_BE_MMIO;
        if (pdata->no_big_frame_no)
                ohci->flags |= OHCI_QUIRK_FRAME_NO;
-
-       ohci_hcd_init(ohci);
-
        if (pdata->num_ports)
                ohci->num_ports = pdata->num_ports;
 
-       err = ohci_init(ohci);
-
-       return err;
-}
-
-static int ohci_platform_start(struct usb_hcd *hcd)
-{
-       struct ohci_hcd *ohci = hcd_to_ohci(hcd);
-       int err;
-
-       err = ohci_run(ohci);
-       if (err < 0) {
-               ohci_err(ohci, "can't start\n");
-               ohci_stop(hcd);
-       }
-
-       return err;
+       return ohci_setup(hcd);
 }
 
-static const struct hc_driver ohci_platform_hc_driver = {
-       .description            = hcd_name,
-       .product_desc           = "Generic Platform OHCI Controller",
-       .hcd_priv_size          = sizeof(struct ohci_hcd),
+static struct hc_driver __read_mostly ohci_platform_hc_driver;
 
-       .irq                    = ohci_irq,
-       .flags                  = HCD_MEMORY | HCD_USB11,
-
-       .reset                  = ohci_platform_reset,
-       .start                  = ohci_platform_start,
-       .stop                   = ohci_stop,
-       .shutdown               = ohci_shutdown,
-
-       .urb_enqueue            = ohci_urb_enqueue,
-       .urb_dequeue            = ohci_urb_dequeue,
-       .endpoint_disable       = ohci_endpoint_disable,
-
-       .get_frame_number       = ohci_get_frame,
-
-       .hub_status_data        = ohci_hub_status_data,
-       .hub_control            = ohci_hub_control,
-#ifdef CONFIG_PM
-       .bus_suspend            = ohci_bus_suspend,
-       .bus_resume             = ohci_bus_resume,
-#endif
-
-       .start_port_reset       = ohci_start_port_reset,
+static const struct ohci_driver_overrides platform_overrides __initconst = {
+       .product_desc = "Generic Platform OHCI controller",
+       .reset =        ohci_platform_reset,
 };
 
 static int ohci_platform_probe(struct platform_device *dev)
@@ -222,3 +193,26 @@ static struct platform_driver ohci_platform_driver = {
                .pm     = &ohci_platform_pm_ops,
        }
 };
+
+static int __init ohci_platform_init(void)
+{
+       if (usb_disabled())
+               return -ENODEV;
+
+       pr_info("%s: " DRIVER_DESC "\n", hcd_name);
+
+       ohci_init_driver(&ohci_platform_hc_driver, &platform_overrides);
+       return platform_driver_register(&ohci_platform_driver);
+}
+module_init(ohci_platform_init);
+
+static void __exit ohci_platform_cleanup(void)
+{
+       platform_driver_unregister(&ohci_platform_driver);
+}
+module_exit(ohci_platform_cleanup);
+
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_AUTHOR("Hauke Mehrtens");
+MODULE_AUTHOR("Alan Stern");
+MODULE_LICENSE("GPL");