diff options
author | Andrew Bresticker <abrestic@chromium.org> | 2014-10-03 04:35:29 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-10-03 17:44:45 -0400 |
commit | 29e409f0f7613f9fd2235e41f0fa33e48e94544e (patch) | |
tree | 3cbc0c17d8e7bfb2c86466b4cdfaac75c4abd423 | |
parent | 436e8c7d457ff4ca89beca20cf54f5884de6af61 (diff) |
xhci: Allow xHCI drivers to be built as separate modules
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>
-rw-r--r-- | drivers/usb/host/Kconfig | 5 | ||||
-rw-r--r-- | drivers/usb/host/Makefile | 12 | ||||
-rw-r--r-- | drivers/usb/host/xhci-pci.c | 9 | ||||
-rw-r--r-- | drivers/usb/host/xhci-plat.c | 9 | ||||
-rw-r--r-- | drivers/usb/host/xhci.c | 22 | ||||
-rw-r--r-- | drivers/usb/host/xhci.h | 19 |
6 files changed, 25 insertions, 51 deletions
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 002ba1d5bcf5..fa038a2e30b2 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
@@ -26,6 +26,11 @@ config USB_XHCI_HCD | |||
26 | 26 | ||
27 | if USB_XHCI_HCD | 27 | if USB_XHCI_HCD |
28 | 28 | ||
29 | config USB_XHCI_PCI | ||
30 | tristate | ||
31 | depends on PCI | ||
32 | default y | ||
33 | |||
29 | config USB_XHCI_PLATFORM | 34 | config USB_XHCI_PLATFORM |
30 | tristate | 35 | tristate |
31 | 36 | ||
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index 0336bb2c0e6f..8c6918907b15 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile | |||
@@ -15,22 +15,22 @@ fhci-$(CONFIG_FHCI_DEBUG) += fhci-dbg.o | |||
15 | xhci-hcd-y := xhci.o xhci-mem.o | 15 | xhci-hcd-y := xhci.o xhci-mem.o |
16 | xhci-hcd-y += xhci-ring.o xhci-hub.o xhci-dbg.o | 16 | xhci-hcd-y += xhci-ring.o xhci-hub.o xhci-dbg.o |
17 | xhci-hcd-y += xhci-trace.o | 17 | xhci-hcd-y += xhci-trace.o |
18 | xhci-hcd-$(CONFIG_PCI) += xhci-pci.o | ||
19 | 18 | ||
20 | ifneq ($(CONFIG_USB_XHCI_PLATFORM), ) | 19 | xhci-plat-hcd-y := xhci-plat.o |
21 | xhci-hcd-y += xhci-plat.o | ||
22 | ifneq ($(CONFIG_USB_XHCI_MVEBU), ) | 20 | ifneq ($(CONFIG_USB_XHCI_MVEBU), ) |
23 | xhci-hcd-y += xhci-mvebu.o | 21 | xhci-plat-hcd-y += xhci-mvebu.o |
24 | endif | 22 | endif |
25 | ifneq ($(CONFIG_USB_XHCI_RCAR), ) | 23 | ifneq ($(CONFIG_USB_XHCI_RCAR), ) |
26 | xhci-hcd-y += xhci-rcar.o | 24 | xhci-plat-hcd-y += xhci-rcar.o |
27 | endif | ||
28 | endif | 25 | endif |
29 | 26 | ||
30 | obj-$(CONFIG_USB_WHCI_HCD) += whci/ | 27 | obj-$(CONFIG_USB_WHCI_HCD) += whci/ |
31 | 28 | ||
32 | obj-$(CONFIG_PCI) += pci-quirks.o | 29 | obj-$(CONFIG_PCI) += pci-quirks.o |
33 | 30 | ||
31 | obj-$(CONFIG_USB_XHCI_PCI) += xhci-pci.o | ||
32 | obj-$(CONFIG_USB_XHCI_PLATFORM) += xhci-plat-hcd.o | ||
33 | |||
34 | obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o | 34 | obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o |
35 | obj-$(CONFIG_USB_EHCI_PCI) += ehci-pci.o | 35 | obj-$(CONFIG_USB_EHCI_PCI) += ehci-pci.o |
36 | obj-$(CONFIG_USB_EHCI_HCD_PLATFORM) += ehci-platform.o | 36 | obj-$(CONFIG_USB_EHCI_HCD_PLATFORM) += ehci-platform.o |
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index effa62aa4a2e..280dde93abe5 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c | |||
@@ -355,7 +355,7 @@ static struct pci_driver xhci_pci_driver = { | |||
355 | #endif | 355 | #endif |
356 | }; | 356 | }; |
357 | 357 | ||
358 | int __init xhci_register_pci(void) | 358 | static int __init xhci_pci_init(void) |
359 | { | 359 | { |
360 | xhci_init_driver(&xhci_pci_hc_driver, xhci_pci_setup); | 360 | xhci_init_driver(&xhci_pci_hc_driver, xhci_pci_setup); |
361 | #ifdef CONFIG_PM | 361 | #ifdef CONFIG_PM |
@@ -364,8 +364,13 @@ int __init xhci_register_pci(void) | |||
364 | #endif | 364 | #endif |
365 | return pci_register_driver(&xhci_pci_driver); | 365 | return pci_register_driver(&xhci_pci_driver); |
366 | } | 366 | } |
367 | module_init(xhci_pci_init); | ||
367 | 368 | ||
368 | void xhci_unregister_pci(void) | 369 | static void __exit xhci_pci_exit(void) |
369 | { | 370 | { |
370 | pci_unregister_driver(&xhci_pci_driver); | 371 | pci_unregister_driver(&xhci_pci_driver); |
371 | } | 372 | } |
373 | module_exit(xhci_pci_exit); | ||
374 | |||
375 | MODULE_DESCRIPTION("xHCI PCI Host Controller Driver"); | ||
376 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index f35236805a62..3d78b0cd674b 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c | |||
@@ -247,14 +247,19 @@ static struct platform_driver usb_xhci_driver = { | |||
247 | }; | 247 | }; |
248 | MODULE_ALIAS("platform:xhci-hcd"); | 248 | MODULE_ALIAS("platform:xhci-hcd"); |
249 | 249 | ||
250 | int xhci_register_plat(void) | 250 | static int __init xhci_plat_init(void) |
251 | { | 251 | { |
252 | xhci_init_driver(&xhci_plat_hc_driver, xhci_plat_setup); | 252 | xhci_init_driver(&xhci_plat_hc_driver, xhci_plat_setup); |
253 | xhci_plat_hc_driver.start = xhci_plat_start; | 253 | xhci_plat_hc_driver.start = xhci_plat_start; |
254 | return platform_driver_register(&usb_xhci_driver); | 254 | return platform_driver_register(&usb_xhci_driver); |
255 | } | 255 | } |
256 | module_init(xhci_plat_init); | ||
256 | 257 | ||
257 | void xhci_unregister_plat(void) | 258 | static void __exit xhci_plat_exit(void) |
258 | { | 259 | { |
259 | platform_driver_unregister(&usb_xhci_driver); | 260 | platform_driver_unregister(&usb_xhci_driver); |
260 | } | 261 | } |
262 | module_exit(xhci_plat_exit); | ||
263 | |||
264 | MODULE_DESCRIPTION("xHCI Platform Host Controller Driver"); | ||
265 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 3e0f5c7aed7a..2a5d45b4cb15 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c | |||
@@ -4982,18 +4982,6 @@ MODULE_LICENSE("GPL"); | |||
4982 | 4982 | ||
4983 | static int __init xhci_hcd_init(void) | 4983 | static int __init xhci_hcd_init(void) |
4984 | { | 4984 | { |
4985 | int retval; | ||
4986 | |||
4987 | retval = xhci_register_pci(); | ||
4988 | if (retval < 0) { | ||
4989 | pr_debug("Problem registering PCI driver.\n"); | ||
4990 | return retval; | ||
4991 | } | ||
4992 | retval = xhci_register_plat(); | ||
4993 | if (retval < 0) { | ||
4994 | pr_debug("Problem registering platform driver.\n"); | ||
4995 | goto unreg_pci; | ||
4996 | } | ||
4997 | /* | 4985 | /* |
4998 | * Check the compiler generated sizes of structures that must be laid | 4986 | * Check the compiler generated sizes of structures that must be laid |
4999 | * out in specific ways for hardware access. | 4987 | * out in specific ways for hardware access. |
@@ -5012,15 +5000,5 @@ static int __init xhci_hcd_init(void) | |||
5012 | /* xhci_run_regs has eight fields and embeds 128 xhci_intr_regs */ | 5000 | /* xhci_run_regs has eight fields and embeds 128 xhci_intr_regs */ |
5013 | BUILD_BUG_ON(sizeof(struct xhci_run_regs) != (8+8*128)*32/8); | 5001 | BUILD_BUG_ON(sizeof(struct xhci_run_regs) != (8+8*128)*32/8); |
5014 | return 0; | 5002 | return 0; |
5015 | unreg_pci: | ||
5016 | xhci_unregister_pci(); | ||
5017 | return retval; | ||
5018 | } | 5003 | } |
5019 | module_init(xhci_hcd_init); | 5004 | module_init(xhci_hcd_init); |
5020 | |||
5021 | static void __exit xhci_hcd_cleanup(void) | ||
5022 | { | ||
5023 | xhci_unregister_pci(); | ||
5024 | xhci_unregister_plat(); | ||
5025 | } | ||
5026 | module_exit(xhci_hcd_cleanup); | ||
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index a099f382bee0..df76d642e719 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h | |||
@@ -1731,25 +1731,6 @@ void xhci_urb_free_priv(struct xhci_hcd *xhci, struct urb_priv *urb_priv); | |||
1731 | void xhci_free_command(struct xhci_hcd *xhci, | 1731 | void xhci_free_command(struct xhci_hcd *xhci, |
1732 | struct xhci_command *command); | 1732 | struct xhci_command *command); |
1733 | 1733 | ||
1734 | #ifdef CONFIG_PCI | ||
1735 | /* xHCI PCI glue */ | ||
1736 | int xhci_register_pci(void); | ||
1737 | void xhci_unregister_pci(void); | ||
1738 | #else | ||
1739 | static inline int xhci_register_pci(void) { return 0; } | ||
1740 | static inline void xhci_unregister_pci(void) {} | ||
1741 | #endif | ||
1742 | |||
1743 | #if IS_ENABLED(CONFIG_USB_XHCI_PLATFORM) | ||
1744 | int xhci_register_plat(void); | ||
1745 | void xhci_unregister_plat(void); | ||
1746 | #else | ||
1747 | static inline int xhci_register_plat(void) | ||
1748 | { return 0; } | ||
1749 | static inline void xhci_unregister_plat(void) | ||
1750 | { } | ||
1751 | #endif | ||
1752 | |||
1753 | /* xHCI host controller glue */ | 1734 | /* xHCI host controller glue */ |
1754 | typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *); | 1735 | typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *); |
1755 | int xhci_handshake(struct xhci_hcd *xhci, void __iomem *ptr, | 1736 | int xhci_handshake(struct xhci_hcd *xhci, void __iomem *ptr, |