xhci: Allow xHCI drivers to be built as separate modules
authorAndrew Bresticker <abrestic@chromium.org>
Fri, 3 Oct 2014 08:35:29 +0000 (11:35 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 3 Oct 2014 21:44:45 +0000 (14:44 -0700)
Instead of building all of the xHCI code into a single module, separate
it out into the core (xhci-hcd), PCI (xhci-pci, now selected by the new
config option CONFIG_USB_XHCI_PCI), and platform (xhci-plat) drivers.
Also update the PCI/platform drivers with module descriptions/licenses
and have them register their respective drivers in their initcalls.

Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/Kconfig
drivers/usb/host/Makefile
drivers/usb/host/xhci-pci.c
drivers/usb/host/xhci-plat.c
drivers/usb/host/xhci.c
drivers/usb/host/xhci.h

index 002ba1d5bcf564116e9a14851ee83932002f1fe6..fa038a2e30b2f107bf7f03e75290a7ca90390de9 100644 (file)
@@ -26,6 +26,11 @@ config USB_XHCI_HCD
 
 if USB_XHCI_HCD
 
+config USB_XHCI_PCI
+       tristate
+       depends on PCI
+       default y
+
 config USB_XHCI_PLATFORM
        tristate
 
index 0336bb2c0e6f6688a5fa2d6d05dc944908772822..8c6918907b15ade4aae2a24d5d3f2c3fcb62b3bf 100644 (file)
@@ -15,22 +15,22 @@ fhci-$(CONFIG_FHCI_DEBUG) += fhci-dbg.o
 xhci-hcd-y := xhci.o xhci-mem.o
 xhci-hcd-y += xhci-ring.o xhci-hub.o xhci-dbg.o
 xhci-hcd-y += xhci-trace.o
-xhci-hcd-$(CONFIG_PCI) += xhci-pci.o
 
-ifneq ($(CONFIG_USB_XHCI_PLATFORM), )
-       xhci-hcd-y              += xhci-plat.o
+xhci-plat-hcd-y := xhci-plat.o
 ifneq ($(CONFIG_USB_XHCI_MVEBU), )
-       xhci-hcd-y              += xhci-mvebu.o
+       xhci-plat-hcd-y         += xhci-mvebu.o
 endif
 ifneq ($(CONFIG_USB_XHCI_RCAR), )
-       xhci-hcd-y              += xhci-rcar.o
-endif
+       xhci-plat-hcd-y         += xhci-rcar.o
 endif
 
 obj-$(CONFIG_USB_WHCI_HCD)     += whci/
 
 obj-$(CONFIG_PCI)              += pci-quirks.o
 
+obj-$(CONFIG_USB_XHCI_PCI)     += xhci-pci.o
+obj-$(CONFIG_USB_XHCI_PLATFORM) += xhci-plat-hcd.o
+
 obj-$(CONFIG_USB_EHCI_HCD)     += ehci-hcd.o
 obj-$(CONFIG_USB_EHCI_PCI)     += ehci-pci.o
 obj-$(CONFIG_USB_EHCI_HCD_PLATFORM)    += ehci-platform.o
index effa62aa4a2e32b7edd66c4e12a95a478bff1b29..280dde93abe528ba61e98fa4790c1fada555794f 100644 (file)
@@ -355,7 +355,7 @@ static struct pci_driver xhci_pci_driver = {
 #endif
 };
 
-int __init xhci_register_pci(void)
+static int __init xhci_pci_init(void)
 {
        xhci_init_driver(&xhci_pci_hc_driver, xhci_pci_setup);
 #ifdef CONFIG_PM
@@ -364,8 +364,13 @@ int __init xhci_register_pci(void)
 #endif
        return pci_register_driver(&xhci_pci_driver);
 }
+module_init(xhci_pci_init);
 
-void xhci_unregister_pci(void)
+static void __exit xhci_pci_exit(void)
 {
        pci_unregister_driver(&xhci_pci_driver);
 }
+module_exit(xhci_pci_exit);
+
+MODULE_DESCRIPTION("xHCI PCI Host Controller Driver");
+MODULE_LICENSE("GPL");
index f35236805a6223d1e1df7e6f4bd0ba8db2cd709c..3d78b0cd674b4cd07485dfe493b3cd67d0253fdf 100644 (file)
@@ -247,14 +247,19 @@ static struct platform_driver usb_xhci_driver = {
 };
 MODULE_ALIAS("platform:xhci-hcd");
 
-int xhci_register_plat(void)
+static int __init xhci_plat_init(void)
 {
        xhci_init_driver(&xhci_plat_hc_driver, xhci_plat_setup);
        xhci_plat_hc_driver.start = xhci_plat_start;
        return platform_driver_register(&usb_xhci_driver);
 }
+module_init(xhci_plat_init);
 
-void xhci_unregister_plat(void)
+static void __exit xhci_plat_exit(void)
 {
        platform_driver_unregister(&usb_xhci_driver);
 }
+module_exit(xhci_plat_exit);
+
+MODULE_DESCRIPTION("xHCI Platform Host Controller Driver");
+MODULE_LICENSE("GPL");
index 3e0f5c7aed7a48a531ed5960808e26e3d62fca08..2a5d45b4cb15ef30d82294de6c5d8e015449a383 100644 (file)
@@ -4982,18 +4982,6 @@ MODULE_LICENSE("GPL");
 
 static int __init xhci_hcd_init(void)
 {
-       int retval;
-
-       retval = xhci_register_pci();
-       if (retval < 0) {
-               pr_debug("Problem registering PCI driver.\n");
-               return retval;
-       }
-       retval = xhci_register_plat();
-       if (retval < 0) {
-               pr_debug("Problem registering platform driver.\n");
-               goto unreg_pci;
-       }
        /*
         * Check the compiler generated sizes of structures that must be laid
         * out in specific ways for hardware access.
@@ -5012,15 +5000,5 @@ static int __init xhci_hcd_init(void)
        /* xhci_run_regs has eight fields and embeds 128 xhci_intr_regs */
        BUILD_BUG_ON(sizeof(struct xhci_run_regs) != (8+8*128)*32/8);
        return 0;
-unreg_pci:
-       xhci_unregister_pci();
-       return retval;
 }
 module_init(xhci_hcd_init);
-
-static void __exit xhci_hcd_cleanup(void)
-{
-       xhci_unregister_pci();
-       xhci_unregister_plat();
-}
-module_exit(xhci_hcd_cleanup);
index a099f382bee0e0716bce496ec7e5c04abd0e0719..df76d642e7190bd04854a10024c06714dd7e48d0 100644 (file)
@@ -1731,25 +1731,6 @@ void xhci_urb_free_priv(struct xhci_hcd *xhci, struct urb_priv *urb_priv);
 void xhci_free_command(struct xhci_hcd *xhci,
                struct xhci_command *command);
 
-#ifdef CONFIG_PCI
-/* xHCI PCI glue */
-int xhci_register_pci(void);
-void xhci_unregister_pci(void);
-#else
-static inline int xhci_register_pci(void) { return 0; }
-static inline void xhci_unregister_pci(void) {}
-#endif
-
-#if IS_ENABLED(CONFIG_USB_XHCI_PLATFORM)
-int xhci_register_plat(void);
-void xhci_unregister_plat(void);
-#else
-static inline int xhci_register_plat(void)
-{ return 0; }
-static inline void xhci_unregister_plat(void)
-{  }
-#endif
-
 /* xHCI host controller glue */
 typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *);
 int xhci_handshake(struct xhci_hcd *xhci, void __iomem *ptr,