]> pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
ohci: Rework bus glue integration to allow several at once
authorSylvain Munaut <tnt@246tNt.com>
Wed, 13 Dec 2006 20:09:54 +0000 (21:09 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 7 Feb 2007 23:44:33 +0000 (15:44 -0800)
The previous model had the module_init & module_exit function in the
bus glue .c files themselves. That's a problem if several glues need
to be selected at once and the driver is built has module. This case
is quite common in embedded system where you want to handle both the
integrated ohci controller and some extra controller on PCI.

The ohci-hcd.c file now provide the module_init & module_exit and
appropriate driver registering/unregistering is done conditionally,
using #ifdefs.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
13 files changed:
drivers/usb/host/ohci-at91.c
drivers/usb/host/ohci-au1xxx.c
drivers/usb/host/ohci-ep93xx.c
drivers/usb/host/ohci-hcd.c
drivers/usb/host/ohci-lh7a404.c
drivers/usb/host/ohci-omap.c
drivers/usb/host/ohci-pci.c
drivers/usb/host/ohci-pnx4008.c
drivers/usb/host/ohci-pnx8550.c
drivers/usb/host/ohci-ppc-soc.c
drivers/usb/host/ohci-pxa27x.c
drivers/usb/host/ohci-s3c2410.c
drivers/usb/host/ohci-sa1111.c

index cc405512fa1c0960ea19f1072bc8768f0889ca1c..53f62cf7698b5b7a0c7e496a6dcf55bfdb9fe972 100644 (file)
@@ -320,18 +320,3 @@ static struct platform_driver ohci_hcd_at91_driver = {
        },
 };
 
-static int __init ohci_hcd_at91_init (void)
-{
-       if (usb_disabled())
-               return -ENODEV;
-
-       return platform_driver_register(&ohci_hcd_at91_driver);
-}
-
-static void __exit ohci_hcd_at91_cleanup (void)
-{
-       platform_driver_unregister(&ohci_hcd_at91_driver);
-}
-
-module_init (ohci_hcd_at91_init);
-module_exit (ohci_hcd_at91_cleanup);
index e70b2430e2a9f610777ed415c6a8bcb91b6585f9..663a0600b6e7564e3e158dab472e74ddf4091c5d 100644 (file)
@@ -345,19 +345,3 @@ static struct platform_driver ohci_hcd_au1xxx_driver = {
        },
 };
 
-static int __init ohci_hcd_au1xxx_init (void)
-{
-       pr_debug (DRIVER_INFO " (Au1xxx)");
-       pr_debug ("block sizes: ed %d td %d\n",
-               sizeof (struct ed), sizeof (struct td));
-
-       return platform_driver_register(&ohci_hcd_au1xxx_driver);
-}
-
-static void __exit ohci_hcd_au1xxx_cleanup (void)
-{
-       platform_driver_unregister(&ohci_hcd_au1xxx_driver);
-}
-
-module_init (ohci_hcd_au1xxx_init);
-module_exit (ohci_hcd_au1xxx_cleanup);
index 3348b07f0fe507209a261575d43d1d15073b7d55..44c60fba76e166b68a5be67a9b47f6fc7fd5d526 100644 (file)
@@ -214,15 +214,3 @@ static struct platform_driver ohci_hcd_ep93xx_driver = {
        },
 };
 
-static int __init ohci_hcd_ep93xx_init(void)
-{
-       return platform_driver_register(&ohci_hcd_ep93xx_driver);
-}
-
-static void __exit ohci_hcd_ep93xx_cleanup(void)
-{
-       platform_driver_unregister(&ohci_hcd_ep93xx_driver);
-}
-
-module_init(ohci_hcd_ep93xx_init);
-module_exit(ohci_hcd_ep93xx_cleanup);
index c1c1d871aba4b630067c90c8fa04c86bf3377c84..3f80003b40bd0f87d50709081569135277274535 100644 (file)
@@ -855,63 +855,131 @@ MODULE_LICENSE ("GPL");
 
 #ifdef CONFIG_PCI
 #include "ohci-pci.c"
+#define PCI_DRIVER             ohci_pci_driver
 #endif
 
 #ifdef CONFIG_SA1111
 #include "ohci-sa1111.c"
+#define SA1111_DRIVER          ohci_hcd_sa1111_driver
 #endif
 
 #ifdef CONFIG_ARCH_S3C2410
 #include "ohci-s3c2410.c"
+#define PLATFORM_DRIVER                ohci_hcd_s3c2410_driver
 #endif
 
 #ifdef CONFIG_ARCH_OMAP
 #include "ohci-omap.c"
+#define PLATFORM_DRIVER                ohci_hcd_omap_driver
 #endif
 
 #ifdef CONFIG_ARCH_LH7A404
 #include "ohci-lh7a404.c"
+#define PLATFORM_DRIVER                ohci_hcd_lh7a404_driver
 #endif
 
 #ifdef CONFIG_PXA27x
 #include "ohci-pxa27x.c"
+#define PLATFORM_DRIVER                ohci_hcd_pxa27x_driver
 #endif
 
 #ifdef CONFIG_ARCH_EP93XX
 #include "ohci-ep93xx.c"
+#define PLATFORM_DRIVER                ohci_hcd_ep93xx_driver
 #endif
 
 #ifdef CONFIG_SOC_AU1X00
 #include "ohci-au1xxx.c"
+#define PLATFORM_DRIVER                ohci_hcd_au1xxx_driver
 #endif
 
 #ifdef CONFIG_PNX8550
 #include "ohci-pnx8550.c"
+#define PLATFORM_DRIVER                ohci_hcd_pnx8550_driver
 #endif
 
 #ifdef CONFIG_USB_OHCI_HCD_PPC_SOC
 #include "ohci-ppc-soc.c"
+#define PLATFORM_DRIVER                ohci_hcd_ppc_soc_driver
 #endif
 
 #ifdef CONFIG_ARCH_AT91
 #include "ohci-at91.c"
+#define PLATFORM_DRIVER                ohci_hcd_at91_driver
 #endif
 
 #ifdef CONFIG_ARCH_PNX4008
 #include "ohci-pnx4008.c"
+#define PLATFORM_DRIVER                usb_hcd_pnx4008_driver
 #endif
 
-#if !(defined(CONFIG_PCI) \
-      || defined(CONFIG_SA1111) \
-      || defined(CONFIG_ARCH_S3C2410) \
-      || defined(CONFIG_ARCH_OMAP) \
-      || defined (CONFIG_ARCH_LH7A404) \
-      || defined (CONFIG_PXA27x) \
-      || defined (CONFIG_ARCH_EP93XX) \
-      || defined (CONFIG_SOC_AU1X00) \
-      || defined (CONFIG_USB_OHCI_HCD_PPC_SOC) \
-      || defined (CONFIG_ARCH_AT91) \
-      || defined (CONFIG_ARCH_PNX4008) \
-       )
+
+#if    !defined(PCI_DRIVER) &&         \
+       !defined(PLATFORM_DRIVER) &&    \
+       !defined(SA1111_DRIVER)
 #error "missing bus glue for ohci-hcd"
 #endif
+
+static int __init ohci_hcd_mod_init(void)
+{
+       int retval = 0;
+       int ls = 0;
+
+       if (usb_disabled())
+               return -ENODEV;
+
+       printk (KERN_DEBUG "%s: " DRIVER_INFO "\n", hcd_name);
+       pr_debug ("%s: block sizes: ed %Zd td %Zd\n", hcd_name,
+               sizeof (struct ed), sizeof (struct td));
+
+#ifdef PLATFORM_DRIVER
+       retval = platform_driver_register(&PLATFORM_DRIVER);
+       if (retval < 0)
+               return retval;
+       ls++;
+#endif
+
+#ifdef SA1111_DRIVER
+       retval = sa1111_driver_register(&SA1111_DRIVER);
+       if (retval < 0)
+               goto error;
+       ls++;
+#endif
+
+#ifdef PCI_DRIVER
+       retval = pci_register_driver(&PCI_DRIVER);
+       if (retval < 0)
+               goto error;
+       ls++;
+#endif
+
+       return retval;
+
+       /* Error path */
+error:
+#ifdef PLATFORM_DRIVER
+       if (ls--)
+               platform_driver_unregister(&PLATFORM_DRIVER);
+#endif
+#ifdef SA1111_DRIVER
+       if (ls--)
+               sa1111_driver_unregister(&SA1111_DRIVER);
+#endif
+       return retval;
+}
+module_init(ohci_hcd_mod_init);
+
+static void __exit ohci_hcd_mod_exit(void)
+{
+#ifdef PCI_DRIVER
+       pci_unregister_driver(&PCI_DRIVER);
+#endif
+#ifdef SA1111_DRIVER
+       sa1111_driver_unregister(&SA1111_DRIVER);
+#endif
+#ifdef PLATFORM_DRIVER
+       platform_driver_unregister(&PLATFORM_DRIVER);
+#endif
+}
+module_exit(ohci_hcd_mod_exit);
+
index e9807cf73a2fac93b53a5608a906c763b8663e33..4a043abd85ea2b162feceed92e19738b90aed7e2 100644 (file)
@@ -251,19 +251,3 @@ static struct platform_driver ohci_hcd_lh7a404_driver = {
        },
 };
 
-static int __init ohci_hcd_lh7a404_init (void)
-{
-       pr_debug (DRIVER_INFO " (LH7A404)");
-       pr_debug ("block sizes: ed %d td %d\n",
-               sizeof (struct ed), sizeof (struct td));
-
-       return platform_driver_register(&ohci_hcd_lh7a404_driver);
-}
-
-static void __exit ohci_hcd_lh7a404_cleanup (void)
-{
-       platform_driver_unregister(&ohci_hcd_lh7a404_driver);
-}
-
-module_init (ohci_hcd_lh7a404_init);
-module_exit (ohci_hcd_lh7a404_cleanup);
index 27be1f9368853925da47e2b64cd18fb3ec59088e..5cfa3d1c4413ff3d920cde36b2efceac7a585887 100644 (file)
@@ -544,22 +544,3 @@ static struct platform_driver ohci_hcd_omap_driver = {
        },
 };
 
-static int __init ohci_hcd_omap_init (void)
-{
-       printk (KERN_DEBUG "%s: " DRIVER_INFO " (OMAP)\n", hcd_name);
-       if (usb_disabled())
-               return -ENODEV;
-
-       pr_debug("%s: block sizes: ed %Zd td %Zd\n", hcd_name,
-               sizeof (struct ed), sizeof (struct td));
-
-       return platform_driver_register(&ohci_hcd_omap_driver);
-}
-
-static void __exit ohci_hcd_omap_cleanup (void)
-{
-       platform_driver_unregister(&ohci_hcd_omap_driver);
-}
-
-module_init (ohci_hcd_omap_init);
-module_exit (ohci_hcd_omap_cleanup);
index 292daf044b62da49b5c2f76d34af3a57c8156ee9..b331ac4d0d62e619865d21bc102aa7767ad33970 100644 (file)
@@ -311,23 +311,3 @@ static struct pci_driver ohci_pci_driver = {
        .shutdown =     usb_hcd_pci_shutdown,
 };
 
-
-static int __init ohci_hcd_pci_init (void)
-{
-       printk (KERN_DEBUG "%s: " DRIVER_INFO " (PCI)\n", hcd_name);
-       if (usb_disabled())
-               return -ENODEV;
-
-       pr_debug ("%s: block sizes: ed %Zd td %Zd\n", hcd_name,
-               sizeof (struct ed), sizeof (struct td));
-       return pci_register_driver (&ohci_pci_driver);
-}
-module_init (ohci_hcd_pci_init);
-
-/*-------------------------------------------------------------------------*/
-
-static void __exit ohci_hcd_pci_cleanup (void)
-{
-       pci_unregister_driver (&ohci_pci_driver);
-}
-module_exit (ohci_hcd_pci_cleanup);
index 3a8cbfb69054c00c40e2d2705a5cb373dcbb8294..893b172384da65f223dba59ecd46ed8484e08fbb 100644 (file)
@@ -465,15 +465,3 @@ static struct platform_driver usb_hcd_pnx4008_driver = {
        .remove = usb_hcd_pnx4008_remove,
 };
 
-static int __init usb_hcd_pnx4008_init(void)
-{
-       return platform_driver_register(&usb_hcd_pnx4008_driver);
-}
-
-static void __exit usb_hcd_pnx4008_cleanup(void)
-{
-       return platform_driver_unregister(&usb_hcd_pnx4008_driver);
-}
-
-module_init(usb_hcd_pnx4008_init);
-module_exit(usb_hcd_pnx4008_cleanup);
index 6922b91b17041c0eb3cb11cc26b411fb831f98e8..de45eb0051a7624d52112c19acb6943d252c5164 100644 (file)
@@ -240,19 +240,3 @@ static struct platform_driver ohci_hcd_pnx8550_driver = {
        .remove         = ohci_hcd_pnx8550_drv_remove,
 };
 
-static int __init ohci_hcd_pnx8550_init (void)
-{
-       pr_debug (DRIVER_INFO " (pnx8550)");
-       pr_debug ("block sizes: ed %d td %d\n",
-               sizeof (struct ed), sizeof (struct td));
-
-       return platform_driver_register(&ohci_hcd_pnx8550_driver);
-}
-
-static void __exit ohci_hcd_pnx8550_cleanup (void)
-{
-       platform_driver_unregister(&ohci_hcd_pnx8550_driver);
-}
-
-module_init (ohci_hcd_pnx8550_init);
-module_exit (ohci_hcd_pnx8550_cleanup);
index c7ce8e638a250b592bf12af146b7e49c21ca91a0..1a2e1777ca61c54595992a06c36556eaa67d47ac 100644 (file)
@@ -208,19 +208,3 @@ static struct platform_driver ohci_hcd_ppc_soc_driver = {
        },
 };
 
-static int __init ohci_hcd_ppc_soc_init(void)
-{
-       pr_debug(DRIVER_INFO " (PPC SOC)\n");
-       pr_debug("block sizes: ed %d td %d\n", sizeof(struct ed),
-                                                       sizeof(struct td));
-
-       return platform_driver_register(&ohci_hcd_ppc_soc_driver);
-}
-
-static void __exit ohci_hcd_ppc_soc_cleanup(void)
-{
-       platform_driver_unregister(&ohci_hcd_ppc_soc_driver);
-}
-
-module_init(ohci_hcd_ppc_soc_init);
-module_exit(ohci_hcd_ppc_soc_cleanup);
index 3bbea844a9e34a7e21c845c2323efa4490d6b5e0..f1563dc319d36085276ff35b3030a3f584e07419 100644 (file)
@@ -369,19 +369,3 @@ static struct platform_driver ohci_hcd_pxa27x_driver = {
        },
 };
 
-static int __init ohci_hcd_pxa27x_init (void)
-{
-       pr_debug (DRIVER_INFO " (pxa27x)");
-       pr_debug ("block sizes: ed %d td %d\n",
-               sizeof (struct ed), sizeof (struct td));
-
-       return platform_driver_register(&ohci_hcd_pxa27x_driver);
-}
-
-static void __exit ohci_hcd_pxa27x_cleanup (void)
-{
-       platform_driver_unregister(&ohci_hcd_pxa27x_driver);
-}
-
-module_init (ohci_hcd_pxa27x_init);
-module_exit (ohci_hcd_pxa27x_cleanup);
index b350d45033e7e45de6109da134fa511458106345..6829814b7aafbd6faa17288ebd1999a11ff9dec4 100644 (file)
@@ -501,15 +501,3 @@ static struct platform_driver ohci_hcd_s3c2410_driver = {
        },
 };
 
-static int __init ohci_hcd_s3c2410_init (void)
-{
-       return platform_driver_register(&ohci_hcd_s3c2410_driver);
-}
-
-static void __exit ohci_hcd_s3c2410_cleanup (void)
-{
-       platform_driver_unregister(&ohci_hcd_s3c2410_driver);
-}
-
-module_init (ohci_hcd_s3c2410_init);
-module_exit (ohci_hcd_s3c2410_cleanup);
index fe0090e33675b909a69882251d788bbac134aac8..0f48f2d992263f199ad889e31f8e0f3bf0c4f48d 100644 (file)
@@ -269,19 +269,3 @@ static struct sa1111_driver ohci_hcd_sa1111_driver = {
        .remove         = ohci_hcd_sa1111_drv_remove,
 };
 
-static int __init ohci_hcd_sa1111_init (void)
-{
-       dbg (DRIVER_INFO " (SA-1111)");
-       dbg ("block sizes: ed %d td %d",
-               sizeof (struct ed), sizeof (struct td));
-
-       return sa1111_driver_register(&ohci_hcd_sa1111_driver);
-}
-
-static void __exit ohci_hcd_sa1111_cleanup (void)
-{
-       sa1111_driver_unregister(&ohci_hcd_sa1111_driver);
-}
-
-module_init (ohci_hcd_sa1111_init);
-module_exit (ohci_hcd_sa1111_cleanup);