]> Pileus Git - ~andy/linux/commitdiff
USB: EHCI: make ehci-pci a separate driver
authorAlan Stern <stern@rowland.harvard.edu>
Thu, 1 Nov 2012 15:13:04 +0000 (11:13 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Nov 2012 15:51:12 +0000 (08:51 -0700)
This patch (as1625) splits the PCI portion of ehci-hcd out into its
own separate driver module, called ehci-pci.  Consistently with the
current practice, the decision whether to build this module is not
user-configurable.  If EHCI and PCI are enabled then the module will
be built, always.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/Kconfig
drivers/usb/host/Makefile
drivers/usb/host/ehci-hcd.c
drivers/usb/host/ehci-pci.c

index 8cc06f054c6a3bfa32ebf1ee0af333849feb1b05..10130f47fc78c22da77096b13816e9ec16d24ca8 100644 (file)
@@ -95,6 +95,11 @@ config USB_EHCI_TT_NEWSCHED
 
          If unsure, say Y.
 
+config USB_EHCI_PCI
+       tristate
+       depends on USB_EHCI_HCD && PCI
+       default y
+
 config USB_EHCI_HCD_PMC_MSP
        tristate "EHCI support for on-chip PMC MSP71xx USB controller"
        depends on USB_EHCI_HCD && MSP_HAS_USB
index 332ed897a6fbd4706d8101d5f013fe67c0e48b03..a8390b091c4d5ef4abae21b29f50b0e87af4a21a 100644 (file)
@@ -24,6 +24,8 @@ obj-$(CONFIG_USB_WHCI_HCD)    += whci/
 obj-$(CONFIG_PCI)              += pci-quirks.o
 
 obj-$(CONFIG_USB_EHCI_HCD)     += ehci-hcd.o
+obj-$(CONFIG_USB_EHCI_PCI)     += ehci-pci.o
+
 obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o
 obj-$(CONFIG_USB_ISP116X_HCD)  += isp116x-hcd.o
 obj-$(CONFIG_USB_ISP1362_HCD)  += isp1362-hcd.o
index dee3541bfae821b9c7ad7c0fc1955e14cca02b91..7113d6ad24f7904a0e7001109752d7099b2224e1 100644 (file)
@@ -1252,11 +1252,6 @@ MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_AUTHOR (DRIVER_AUTHOR);
 MODULE_LICENSE ("GPL");
 
-#ifdef CONFIG_PCI
-#include "ehci-pci.c"
-#define        PCI_DRIVER              ehci_pci_driver
-#endif
-
 #ifdef CONFIG_USB_EHCI_FSL
 #include "ehci-fsl.c"
 #define        PLATFORM_DRIVER         ehci_fsl_driver
@@ -1367,9 +1362,11 @@ MODULE_LICENSE ("GPL");
 #define PLATFORM_DRIVER                ehci_platform_driver
 #endif
 
-#if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \
-    !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \
-    !defined(XILINX_OF_PLATFORM_DRIVER)
+#if !IS_ENABLED(CONFIG_USB_EHCI_PCI) && \
+       !defined(PLATFORM_DRIVER) && \
+       !defined(PS3_SYSTEM_BUS_DRIVER) && \
+       !defined(OF_PLATFORM_DRIVER) && \
+       !defined(XILINX_OF_PLATFORM_DRIVER)
 #error "missing bus glue for ehci-hcd"
 #endif
 
@@ -1406,12 +1403,6 @@ static int __init ehci_hcd_init(void)
                goto clean0;
 #endif
 
-#ifdef PCI_DRIVER
-       retval = pci_register_driver(&PCI_DRIVER);
-       if (retval < 0)
-               goto clean1;
-#endif
-
 #ifdef PS3_SYSTEM_BUS_DRIVER
        retval = ps3_ehci_driver_register(&PS3_SYSTEM_BUS_DRIVER);
        if (retval < 0)
@@ -1443,10 +1434,6 @@ clean3:
        ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER);
 clean2:
 #endif
-#ifdef PCI_DRIVER
-       pci_unregister_driver(&PCI_DRIVER);
-clean1:
-#endif
 #ifdef PLATFORM_DRIVER
        platform_driver_unregister(&PLATFORM_DRIVER);
 clean0:
@@ -1472,9 +1459,6 @@ static void __exit ehci_hcd_cleanup(void)
 #ifdef PLATFORM_DRIVER
        platform_driver_unregister(&PLATFORM_DRIVER);
 #endif
-#ifdef PCI_DRIVER
-       pci_unregister_driver(&PCI_DRIVER);
-#endif
 #ifdef PS3_SYSTEM_BUS_DRIVER
        ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER);
 #endif
index c92dcaee0d4d21cd7e4dfe158df025db6df26403..46018e975244743de65fe7f3f42b2d9ed1bc11c3 100644 (file)
  * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#ifndef CONFIG_PCI
-#error "This file is PCI bus glue.  CONFIG_PCI must be defined."
-#endif
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/usb.h>
+#include <linux/usb/hcd.h>
+
+#include "ehci.h"
+#include "pci-quirks.h"
+
+#define DRIVER_DESC "EHCI PCI platform driver"
+
+static const char hcd_name[] = "ehci-pci";
 
 /* defined here to avoid adding to pci_ids.h for single instance use */
 #define PCI_DEVICE_ID_INTEL_CE4100_USB 0x2e70
@@ -315,11 +324,6 @@ done:
  * Also they depend on separate root hub suspend/resume.
  */
 
-static int ehci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
-{
-       return ehci_suspend(hcd, do_wakeup);
-}
-
 static bool usb_is_intel_switchable_ehci(struct pci_dev *pdev)
 {
        return pdev->class == PCI_CLASS_SERIAL_USB_EHCI &&
@@ -370,55 +374,18 @@ static int ehci_pci_resume(struct usb_hcd *hcd, bool hibernated)
                (void) ehci_pci_reinit(ehci, pdev);
        return 0;
 }
-#endif
-
-static const struct hc_driver ehci_pci_hc_driver = {
-       .description =          hcd_name,
-       .product_desc =         "EHCI Host Controller",
-       .hcd_priv_size =        sizeof(struct ehci_hcd),
 
-       /*
-        * generic hardware linkage
-        */
-       .irq =                  ehci_irq,
-       .flags =                HCD_MEMORY | HCD_USB2,
-
-       /*
-        * basic lifecycle operations
-        */
-       .reset =                ehci_pci_setup,
-       .start =                ehci_run,
-#ifdef CONFIG_PM
-       .pci_suspend =          ehci_pci_suspend,
-       .pci_resume =           ehci_pci_resume,
-#endif
-       .stop =                 ehci_stop,
-       .shutdown =             ehci_shutdown,
+#else
 
-       /*
-        * managing i/o requests and associated device resources
-        */
-       .urb_enqueue =          ehci_urb_enqueue,
-       .urb_dequeue =          ehci_urb_dequeue,
-       .endpoint_disable =     ehci_endpoint_disable,
-       .endpoint_reset =       ehci_endpoint_reset,
+#define ehci_suspend           NULL
+#define ehci_pci_resume                NULL
+#endif /* CONFIG_PM */
 
-       /*
-        * scheduling support
-        */
-       .get_frame_number =     ehci_get_frame,
+static struct hc_driver __read_mostly ehci_pci_hc_driver;
 
-       /*
-        * root hub support
-        */
-       .hub_status_data =      ehci_hub_status_data,
-       .hub_control =          ehci_hub_control,
-       .bus_suspend =          ehci_bus_suspend,
-       .bus_resume =           ehci_bus_resume,
-       .relinquish_port =      ehci_relinquish_port,
-       .port_handed_over =     ehci_port_handed_over,
-
-       .clear_tt_buffer_complete       = ehci_clear_tt_buffer_complete,
+static const struct ehci_driver_overrides overrides = {
+       .product_desc =         "EHCI PCI host controller",
+       .reset =                ehci_pci_setup,
 };
 
 /*-------------------------------------------------------------------------*/
@@ -451,3 +418,31 @@ static struct pci_driver ehci_pci_driver = {
        },
 #endif
 };
+
+static int __init ehci_pci_init(void)
+{
+       if (usb_disabled())
+               return -ENODEV;
+
+       pr_info("%s: " DRIVER_DESC "\n", hcd_name);
+
+       ehci_init_driver(&ehci_pci_hc_driver, &overrides);
+
+       /* Entries for the PCI suspend/resume callbacks are special */
+       ehci_pci_hc_driver.pci_suspend = ehci_suspend;
+       ehci_pci_hc_driver.pci_resume = ehci_pci_resume;
+
+       return pci_register_driver(&ehci_pci_driver);
+}
+module_init(ehci_pci_init);
+
+static void __exit ehci_pci_cleanup(void)
+{
+       pci_unregister_driver(&ehci_pci_driver);
+}
+module_exit(ehci_pci_cleanup);
+
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_AUTHOR("David Brownell");
+MODULE_AUTHOR("Alan Stern");
+MODULE_LICENSE("GPL");