Hi,

Below is a patch that solves the compilation issue with ohci-hcd as module when we want to enable platform OHCI controllers and PCI OHCI controllers at the same time. The patch uses the same approach as the similar ehci-hcd.c fix at http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/gregkh-04-usb/usb-allow-multiple-types-of-ehci-controllers-to-be-built-as-modules.patch

and eliminates separate module initialization/cleanup functions in every submodule specific for each platform. The initialization/cleanup of PCI and/or platform driver is now the responsibility of ohci-hcd.

-Jan

Jan Capek
SYSGO | Real-Time Solutions | ELinOS Embedded Linux | http://www.sysgo.com

Signed-off-by: Jan Capek <[EMAIL PROTECTED]>

----
diff -urpN -X /home/jca/doc/misc/dontdiff 
linux-2.6.17-rc5/drivers/usb/host/ohci-at91.c 
linux-2.6.17-rc5-ohci-hcd-patch/drivers/usb/host/ohci-at91.c
--- linux-2.6.17-rc5/drivers/usb/host/ohci-at91.c       2006-05-25 
03:50:17.000000000 +0200
+++ linux-2.6.17-rc5-ohci-hcd-patch/drivers/usb/host/ohci-at91.c        
2006-05-30 10:46:45.000000000 +0200
@@ -287,19 +287,3 @@ static struct platform_driver ohci_hcd_a
                .owner  = THIS_MODULE,
        },
 };
-
-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);
diff -urpN -X /home/jca/doc/misc/dontdiff 
linux-2.6.17-rc5/drivers/usb/host/ohci-au1xxx.c 
linux-2.6.17-rc5-ohci-hcd-patch/drivers/usb/host/ohci-au1xxx.c
--- linux-2.6.17-rc5/drivers/usb/host/ohci-au1xxx.c     2006-05-25 
03:50:17.000000000 +0200
+++ linux-2.6.17-rc5-ohci-hcd-patch/drivers/usb/host/ohci-au1xxx.c      
2006-05-30 10:38:45.000000000 +0200
@@ -344,19 +344,3 @@ static struct platform_driver ohci_hcd_a
        },
 };

-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);
diff -urpN -X /home/jca/doc/misc/dontdiff 
linux-2.6.17-rc5/drivers/usb/host/ohci-hcd.c 
linux-2.6.17-rc5-ohci-hcd-patch/drivers/usb/host/ohci-hcd.c
--- linux-2.6.17-rc5/drivers/usb/host/ohci-hcd.c        2006-05-25 
03:50:17.000000000 +0200
+++ linux-2.6.17-rc5-ohci-hcd-patch/drivers/usb/host/ohci-hcd.c 2006-05-30 
10:46:40.000000000 +0200
@@ -880,49 +880,96 @@ MODULE_LICENSE ("GPL");

 #ifdef CONFIG_PCI
 #include "ohci-pci.c"
+#define        PCI_DRIVER              ohci_pci_driver
 #endif

+/* default platform driver registration/unregistration functions */
+#define platform_driver_register_func   platform_driver_register
+#define platform_driver_unregister_func platform_driver_unregister
+
 #ifdef CONFIG_SA1111
 #include "ohci-sa1111.c"
+#define PLATFORM_DRIVER         ohci_hcd_sa1111_driver
+/* ARM platform uses hardware specific driver registration functions */
+#undef  platform_driver_register_func
+#define platform_driver_register_func   sa1111_driver_register
+#undef  platform_driver_unregister_func
+#define platform_driver_unregister_func sa1111_driver_unregister
 #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"
+#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_SOC_AU1X00
 #include "ohci-au1xxx.c"
+#define PLATFORM_DRIVER         ohci_hcd_au1xxx_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_AT91RM9200
 #include "ohci-at91.c"
+#define PLATFORM_DRIVER         ohci_hcd_at91_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_SOC_AU1X00) \
-      || defined (CONFIG_USB_OHCI_HCD_PPC_SOC) \
-      || defined (CONFIG_ARCH_AT91RM9200) \
-       )
+#if !defined(PCI_DRIVER) && !defined(SA1111_DRIVER)
 #error "missing bus glue for ohci-hcd"
 #endif
+
+
+static int __init ohci_hcd_do_init(void)
+{
+       int retval = 0;
+       pr_debug ("%s: block sizes: ed %d td %d\n", hcd_name
+               sizeof (struct ed), sizeof (struct td));
+
+#ifdef PLATFORM_DRIVER
+       retval = platform_driver_register_func(&PLATFORM_DRIVER);
+ if (retval < 0) + return retval;
+#endif
+
+#ifdef PCI_DRIVER
+       retval = pci_register_driver(&PCI_DRIVER);
+       if (retval < 0) {
+#ifdef PLATFORM_DRIVER
+               platform_driver_unregister_func(&PLATFORM_DRIVER);
+#endif
+       }
+#endif
+
+
+       return retval;
+}
+module_init(ohci_hcd_do_init);
+
+static void __exit ohci_hcd_cleanup(void)
+{
+#ifdef PLATFORM_DRIVER
+       platform_driver_unregister_func(&PLATFORM_DRIVER);
+#endif
+#ifdef PCI_DRIVER
+       pci_unregister_driver(&PCI_DRIVER);
+#endif
+}
+module_exit(ohci_hcd_cleanup);
diff -urpN -X /home/jca/doc/misc/dontdiff 
linux-2.6.17-rc5/drivers/usb/host/ohci-lh7a404.c 
linux-2.6.17-rc5-ohci-hcd-patch/drivers/usb/host/ohci-lh7a404.c
--- linux-2.6.17-rc5/drivers/usb/host/ohci-lh7a404.c    2006-05-25 
03:50:17.000000000 +0200
+++ linux-2.6.17-rc5-ohci-hcd-patch/drivers/usb/host/ohci-lh7a404.c     
2006-05-30 10:38:45.000000000 +0200
@@ -252,19 +252,3 @@ static struct platform_driver ohci_hcd_l
        },
 };

-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);
diff -urpN -X /home/jca/doc/misc/dontdiff 
linux-2.6.17-rc5/drivers/usb/host/ohci-omap.c 
linux-2.6.17-rc5-ohci-hcd-patch/drivers/usb/host/ohci-omap.c
--- linux-2.6.17-rc5/drivers/usb/host/ohci-omap.c       2006-05-25 
03:50:17.000000000 +0200
+++ linux-2.6.17-rc5-ohci-hcd-patch/drivers/usb/host/ohci-omap.c        
2006-05-30 10:38:45.000000000 +0200
@@ -506,26 +506,7 @@ static struct platform_driver ohci_hcd_o
 #endif
        .driver         = {
                .owner  = THIS_MODULE,
-               .name   = "ohci",
+               .name   = "omap-ohci",
        },
 };

-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);
diff -urpN -X /home/jca/doc/misc/dontdiff 
linux-2.6.17-rc5/drivers/usb/host/ohci-pci.c 
linux-2.6.17-rc5-ohci-hcd-patch/drivers/usb/host/ohci-pci.c
--- linux-2.6.17-rc5/drivers/usb/host/ohci-pci.c        2006-05-25 
03:50:17.000000000 +0200
+++ linux-2.6.17-rc5-ohci-hcd-patch/drivers/usb/host/ohci-pci.c 2006-05-30 
10:52:38.000000000 +0200
@@ -225,24 +225,3 @@ static struct pci_driver ohci_pci_driver
        .resume =       usb_hcd_pci_resume,
 #endif
 };
-
- -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);
diff -urpN -X /home/jca/doc/misc/dontdiff 
linux-2.6.17-rc5/drivers/usb/host/ohci-ppc-soc.c 
linux-2.6.17-rc5-ohci-hcd-patch/drivers/usb/host/ohci-ppc-soc.c
--- linux-2.6.17-rc5/drivers/usb/host/ohci-ppc-soc.c    2006-05-25 
03:50:17.000000000 +0200
+++ linux-2.6.17-rc5-ohci-hcd-patch/drivers/usb/host/ohci-ppc-soc.c     
2006-05-30 10:38:45.000000000 +0200
@@ -205,19 +205,3 @@ static struct platform_driver ohci_hcd_p
        },
 };

-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);
diff -urpN -X /home/jca/doc/misc/dontdiff 
linux-2.6.17-rc5/drivers/usb/host/ohci-pxa27x.c 
linux-2.6.17-rc5-ohci-hcd-patch/drivers/usb/host/ohci-pxa27x.c
--- linux-2.6.17-rc5/drivers/usb/host/ohci-pxa27x.c     2006-05-25 
03:50:17.000000000 +0200
+++ linux-2.6.17-rc5-ohci-hcd-patch/drivers/usb/host/ohci-pxa27x.c      
2006-05-30 10:38:45.000000000 +0200
@@ -362,20 +362,3 @@ static struct platform_driver ohci_hcd_p
                .name   = "pxa27x-ohci",
        },
 };
-
-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);
diff -urpN -X /home/jca/doc/misc/dontdiff 
linux-2.6.17-rc5/drivers/usb/host/ohci-s3c2410.c 
linux-2.6.17-rc5-ohci-hcd-patch/drivers/usb/host/ohci-s3c2410.c
--- linux-2.6.17-rc5/drivers/usb/host/ohci-s3c2410.c    2006-05-25 
03:50:17.000000000 +0200
+++ linux-2.6.17-rc5-ohci-hcd-patch/drivers/usb/host/ohci-s3c2410.c     
2006-05-30 10:38:45.000000000 +0200
@@ -498,15 +498,3 @@ static struct platform_driver ohci_hcd_s
        },
 };

-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);
diff -urpN -X /home/jca/doc/misc/dontdiff 
linux-2.6.17-rc5/drivers/usb/host/ohci-sa1111.c 
linux-2.6.17-rc5-ohci-hcd-patch/drivers/usb/host/ohci-sa1111.c
--- linux-2.6.17-rc5/drivers/usb/host/ohci-sa1111.c     2006-05-25 
03:50:17.000000000 +0200
+++ linux-2.6.17-rc5-ohci-hcd-patch/drivers/usb/host/ohci-sa1111.c      
2006-05-30 10:38:45.000000000 +0200
@@ -271,20 +271,3 @@ static struct sa1111_driver ohci_hcd_sa1
        .probe          = ohci_hcd_sa1111_drv_probe,
        .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);



-------------------------------------------------------
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to