aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2006-12-13 15:09:54 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2007-02-07 18:44:33 -0500
commit5e16fabe5dbcff15de6cdcba406195fe6e4380df (patch)
treef6004b46e6e84fd44f4bc352260e9a970f7be279
parentad55d71a3d4401f44b4ddee1412283c99eedd05c (diff)
ohci: Rework bus glue integration to allow several at once
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>
-rw-r--r--drivers/usb/host/ohci-at91.c15
-rw-r--r--drivers/usb/host/ohci-au1xxx.c16
-rw-r--r--drivers/usb/host/ohci-ep93xx.c12
-rw-r--r--drivers/usb/host/ohci-hcd.c92
-rw-r--r--drivers/usb/host/ohci-lh7a404.c16
-rw-r--r--drivers/usb/host/ohci-omap.c19
-rw-r--r--drivers/usb/host/ohci-pci.c20
-rw-r--r--drivers/usb/host/ohci-pnx4008.c12
-rw-r--r--drivers/usb/host/ohci-pnx8550.c16
-rw-r--r--drivers/usb/host/ohci-ppc-soc.c16
-rw-r--r--drivers/usb/host/ohci-pxa27x.c16
-rw-r--r--drivers/usb/host/ohci-s3c2410.c12
-rw-r--r--drivers/usb/host/ohci-sa1111.c16
13 files changed, 80 insertions, 198 deletions
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index cc405512fa1c..53f62cf7698b 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -320,18 +320,3 @@ static struct platform_driver ohci_hcd_at91_driver = {
320 }, 320 },
321}; 321};
322 322
323static int __init ohci_hcd_at91_init (void)
324{
325 if (usb_disabled())
326 return -ENODEV;
327
328 return platform_driver_register(&ohci_hcd_at91_driver);
329}
330
331static void __exit ohci_hcd_at91_cleanup (void)
332{
333 platform_driver_unregister(&ohci_hcd_at91_driver);
334}
335
336module_init (ohci_hcd_at91_init);
337module_exit (ohci_hcd_at91_cleanup);
diff --git a/drivers/usb/host/ohci-au1xxx.c b/drivers/usb/host/ohci-au1xxx.c
index e70b2430e2a9..663a0600b6e7 100644
--- a/drivers/usb/host/ohci-au1xxx.c
+++ b/drivers/usb/host/ohci-au1xxx.c
@@ -345,19 +345,3 @@ static struct platform_driver ohci_hcd_au1xxx_driver = {
345 }, 345 },
346}; 346};
347 347
348static int __init ohci_hcd_au1xxx_init (void)
349{
350 pr_debug (DRIVER_INFO " (Au1xxx)");
351 pr_debug ("block sizes: ed %d td %d\n",
352 sizeof (struct ed), sizeof (struct td));
353
354 return platform_driver_register(&ohci_hcd_au1xxx_driver);
355}
356
357static void __exit ohci_hcd_au1xxx_cleanup (void)
358{
359 platform_driver_unregister(&ohci_hcd_au1xxx_driver);
360}
361
362module_init (ohci_hcd_au1xxx_init);
363module_exit (ohci_hcd_au1xxx_cleanup);
diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c
index 3348b07f0fe5..44c60fba76e1 100644
--- a/drivers/usb/host/ohci-ep93xx.c
+++ b/drivers/usb/host/ohci-ep93xx.c
@@ -214,15 +214,3 @@ static struct platform_driver ohci_hcd_ep93xx_driver = {
214 }, 214 },
215}; 215};
216 216
217static int __init ohci_hcd_ep93xx_init(void)
218{
219 return platform_driver_register(&ohci_hcd_ep93xx_driver);
220}
221
222static void __exit ohci_hcd_ep93xx_cleanup(void)
223{
224 platform_driver_unregister(&ohci_hcd_ep93xx_driver);
225}
226
227module_init(ohci_hcd_ep93xx_init);
228module_exit(ohci_hcd_ep93xx_cleanup);
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index c1c1d871aba4..3f80003b40bd 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -855,63 +855,131 @@ MODULE_LICENSE ("GPL");
855 855
856#ifdef CONFIG_PCI 856#ifdef CONFIG_PCI
857#include "ohci-pci.c" 857#include "ohci-pci.c"
858#define PCI_DRIVER ohci_pci_driver
858#endif 859#endif
859 860
860#ifdef CONFIG_SA1111 861#ifdef CONFIG_SA1111
861#include "ohci-sa1111.c" 862#include "ohci-sa1111.c"
863#define SA1111_DRIVER ohci_hcd_sa1111_driver
862#endif 864#endif
863 865
864#ifdef CONFIG_ARCH_S3C2410 866#ifdef CONFIG_ARCH_S3C2410
865#include "ohci-s3c2410.c" 867#include "ohci-s3c2410.c"
868#define PLATFORM_DRIVER ohci_hcd_s3c2410_driver
866#endif 869#endif
867 870
868#ifdef CONFIG_ARCH_OMAP 871#ifdef CONFIG_ARCH_OMAP
869#include "ohci-omap.c" 872#include "ohci-omap.c"
873#define PLATFORM_DRIVER ohci_hcd_omap_driver
870#endif 874#endif
871 875
872#ifdef CONFIG_ARCH_LH7A404 876#ifdef CONFIG_ARCH_LH7A404
873#include "ohci-lh7a404.c" 877#include "ohci-lh7a404.c"
878#define PLATFORM_DRIVER ohci_hcd_lh7a404_driver
874#endif 879#endif
875 880
876#ifdef CONFIG_PXA27x 881#ifdef CONFIG_PXA27x
877#include "ohci-pxa27x.c" 882#include "ohci-pxa27x.c"
883#define PLATFORM_DRIVER ohci_hcd_pxa27x_driver
878#endif 884#endif
879 885
880#ifdef CONFIG_ARCH_EP93XX 886#ifdef CONFIG_ARCH_EP93XX
881#include "ohci-ep93xx.c" 887#include "ohci-ep93xx.c"
888#define PLATFORM_DRIVER ohci_hcd_ep93xx_driver
882#endif 889#endif
883 890
884#ifdef CONFIG_SOC_AU1X00 891#ifdef CONFIG_SOC_AU1X00
885#include "ohci-au1xxx.c" 892#include "ohci-au1xxx.c"
893#define PLATFORM_DRIVER ohci_hcd_au1xxx_driver
886#endif 894#endif
887 895
888#ifdef CONFIG_PNX8550 896#ifdef CONFIG_PNX8550
889#include "ohci-pnx8550.c" 897#include "ohci-pnx8550.c"
898#define PLATFORM_DRIVER ohci_hcd_pnx8550_driver
890#endif 899#endif
891 900
892#ifdef CONFIG_USB_OHCI_HCD_PPC_SOC 901#ifdef CONFIG_USB_OHCI_HCD_PPC_SOC
893#include "ohci-ppc-soc.c" 902#include "ohci-ppc-soc.c"
903#define PLATFORM_DRIVER ohci_hcd_ppc_soc_driver
894#endif 904#endif
895 905
896#ifdef CONFIG_ARCH_AT91 906#ifdef CONFIG_ARCH_AT91
897#include "ohci-at91.c" 907#include "ohci-at91.c"
908#define PLATFORM_DRIVER ohci_hcd_at91_driver
898#endif 909#endif
899 910
900#ifdef CONFIG_ARCH_PNX4008 911#ifdef CONFIG_ARCH_PNX4008
901#include "ohci-pnx4008.c" 912#include "ohci-pnx4008.c"
913#define PLATFORM_DRIVER usb_hcd_pnx4008_driver
902#endif 914#endif
903 915
904#if !(defined(CONFIG_PCI) \ 916
905 || defined(CONFIG_SA1111) \ 917#if !defined(PCI_DRIVER) && \
906 || defined(CONFIG_ARCH_S3C2410) \ 918 !defined(PLATFORM_DRIVER) && \
907 || defined(CONFIG_ARCH_OMAP) \ 919 !defined(SA1111_DRIVER)
908 || defined (CONFIG_ARCH_LH7A404) \
909 || defined (CONFIG_PXA27x) \
910 || defined (CONFIG_ARCH_EP93XX) \
911 || defined (CONFIG_SOC_AU1X00) \
912 || defined (CONFIG_USB_OHCI_HCD_PPC_SOC) \
913 || defined (CONFIG_ARCH_AT91) \
914 || defined (CONFIG_ARCH_PNX4008) \
915 )
916#error "missing bus glue for ohci-hcd" 920#error "missing bus glue for ohci-hcd"
917#endif 921#endif
922
923static int __init ohci_hcd_mod_init(void)
924{
925 int retval = 0;
926 int ls = 0;
927
928 if (usb_disabled())
929 return -ENODEV;
930
931 printk (KERN_DEBUG "%s: " DRIVER_INFO "\n", hcd_name);
932 pr_debug ("%s: block sizes: ed %Zd td %Zd\n", hcd_name,
933 sizeof (struct ed), sizeof (struct td));
934
935#ifdef PLATFORM_DRIVER
936 retval = platform_driver_register(&PLATFORM_DRIVER);
937 if (retval < 0)
938 return retval;
939 ls++;
940#endif
941
942#ifdef SA1111_DRIVER
943 retval = sa1111_driver_register(&SA1111_DRIVER);
944 if (retval < 0)
945 goto error;
946 ls++;
947#endif
948
949#ifdef PCI_DRIVER
950 retval = pci_register_driver(&PCI_DRIVER);
951 if (retval < 0)
952 goto error;
953 ls++;
954#endif
955
956 return retval;
957
958 /* Error path */
959error:
960#ifdef PLATFORM_DRIVER
961 if (ls--)
962 platform_driver_unregister(&PLATFORM_DRIVER);
963#endif
964#ifdef SA1111_DRIVER
965 if (ls--)
966 sa1111_driver_unregister(&SA1111_DRIVER);
967#endif
968 return retval;
969}
970module_init(ohci_hcd_mod_init);
971
972static void __exit ohci_hcd_mod_exit(void)
973{
974#ifdef PCI_DRIVER
975 pci_unregister_driver(&PCI_DRIVER);
976#endif
977#ifdef SA1111_DRIVER
978 sa1111_driver_unregister(&SA1111_DRIVER);
979#endif
980#ifdef PLATFORM_DRIVER
981 platform_driver_unregister(&PLATFORM_DRIVER);
982#endif
983}
984module_exit(ohci_hcd_mod_exit);
985
diff --git a/drivers/usb/host/ohci-lh7a404.c b/drivers/usb/host/ohci-lh7a404.c
index e9807cf73a2f..4a043abd85ea 100644
--- a/drivers/usb/host/ohci-lh7a404.c
+++ b/drivers/usb/host/ohci-lh7a404.c
@@ -251,19 +251,3 @@ static struct platform_driver ohci_hcd_lh7a404_driver = {
251 }, 251 },
252}; 252};
253 253
254static int __init ohci_hcd_lh7a404_init (void)
255{
256 pr_debug (DRIVER_INFO " (LH7A404)");
257 pr_debug ("block sizes: ed %d td %d\n",
258 sizeof (struct ed), sizeof (struct td));
259
260 return platform_driver_register(&ohci_hcd_lh7a404_driver);
261}
262
263static void __exit ohci_hcd_lh7a404_cleanup (void)
264{
265 platform_driver_unregister(&ohci_hcd_lh7a404_driver);
266}
267
268module_init (ohci_hcd_lh7a404_init);
269module_exit (ohci_hcd_lh7a404_cleanup);
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index 27be1f936885..5cfa3d1c4413 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -544,22 +544,3 @@ static struct platform_driver ohci_hcd_omap_driver = {
544 }, 544 },
545}; 545};
546 546
547static int __init ohci_hcd_omap_init (void)
548{
549 printk (KERN_DEBUG "%s: " DRIVER_INFO " (OMAP)\n", hcd_name);
550 if (usb_disabled())
551 return -ENODEV;
552
553 pr_debug("%s: block sizes: ed %Zd td %Zd\n", hcd_name,
554 sizeof (struct ed), sizeof (struct td));
555
556 return platform_driver_register(&ohci_hcd_omap_driver);
557}
558
559static void __exit ohci_hcd_omap_cleanup (void)
560{
561 platform_driver_unregister(&ohci_hcd_omap_driver);
562}
563
564module_init (ohci_hcd_omap_init);
565module_exit (ohci_hcd_omap_cleanup);
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
index 292daf044b62..b331ac4d0d62 100644
--- a/drivers/usb/host/ohci-pci.c
+++ b/drivers/usb/host/ohci-pci.c
@@ -311,23 +311,3 @@ static struct pci_driver ohci_pci_driver = {
311 .shutdown = usb_hcd_pci_shutdown, 311 .shutdown = usb_hcd_pci_shutdown,
312}; 312};
313 313
314
315static int __init ohci_hcd_pci_init (void)
316{
317 printk (KERN_DEBUG "%s: " DRIVER_INFO " (PCI)\n", hcd_name);
318 if (usb_disabled())
319 return -ENODEV;
320
321 pr_debug ("%s: block sizes: ed %Zd td %Zd\n", hcd_name,
322 sizeof (struct ed), sizeof (struct td));
323 return pci_register_driver (&ohci_pci_driver);
324}
325module_init (ohci_hcd_pci_init);
326
327/*-------------------------------------------------------------------------*/
328
329static void __exit ohci_hcd_pci_cleanup (void)
330{
331 pci_unregister_driver (&ohci_pci_driver);
332}
333module_exit (ohci_hcd_pci_cleanup);
diff --git a/drivers/usb/host/ohci-pnx4008.c b/drivers/usb/host/ohci-pnx4008.c
index 3a8cbfb69054..893b172384da 100644
--- a/drivers/usb/host/ohci-pnx4008.c
+++ b/drivers/usb/host/ohci-pnx4008.c
@@ -465,15 +465,3 @@ static struct platform_driver usb_hcd_pnx4008_driver = {
465 .remove = usb_hcd_pnx4008_remove, 465 .remove = usb_hcd_pnx4008_remove,
466}; 466};
467 467
468static int __init usb_hcd_pnx4008_init(void)
469{
470 return platform_driver_register(&usb_hcd_pnx4008_driver);
471}
472
473static void __exit usb_hcd_pnx4008_cleanup(void)
474{
475 return platform_driver_unregister(&usb_hcd_pnx4008_driver);
476}
477
478module_init(usb_hcd_pnx4008_init);
479module_exit(usb_hcd_pnx4008_cleanup);
diff --git a/drivers/usb/host/ohci-pnx8550.c b/drivers/usb/host/ohci-pnx8550.c
index 6922b91b1704..de45eb0051a7 100644
--- a/drivers/usb/host/ohci-pnx8550.c
+++ b/drivers/usb/host/ohci-pnx8550.c
@@ -240,19 +240,3 @@ static struct platform_driver ohci_hcd_pnx8550_driver = {
240 .remove = ohci_hcd_pnx8550_drv_remove, 240 .remove = ohci_hcd_pnx8550_drv_remove,
241}; 241};
242 242
243static int __init ohci_hcd_pnx8550_init (void)
244{
245 pr_debug (DRIVER_INFO " (pnx8550)");
246 pr_debug ("block sizes: ed %d td %d\n",
247 sizeof (struct ed), sizeof (struct td));
248
249 return platform_driver_register(&ohci_hcd_pnx8550_driver);
250}
251
252static void __exit ohci_hcd_pnx8550_cleanup (void)
253{
254 platform_driver_unregister(&ohci_hcd_pnx8550_driver);
255}
256
257module_init (ohci_hcd_pnx8550_init);
258module_exit (ohci_hcd_pnx8550_cleanup);
diff --git a/drivers/usb/host/ohci-ppc-soc.c b/drivers/usb/host/ohci-ppc-soc.c
index c7ce8e638a25..1a2e1777ca61 100644
--- a/drivers/usb/host/ohci-ppc-soc.c
+++ b/drivers/usb/host/ohci-ppc-soc.c
@@ -208,19 +208,3 @@ static struct platform_driver ohci_hcd_ppc_soc_driver = {
208 }, 208 },
209}; 209};
210 210
211static int __init ohci_hcd_ppc_soc_init(void)
212{
213 pr_debug(DRIVER_INFO " (PPC SOC)\n");
214 pr_debug("block sizes: ed %d td %d\n", sizeof(struct ed),
215 sizeof(struct td));
216
217 return platform_driver_register(&ohci_hcd_ppc_soc_driver);
218}
219
220static void __exit ohci_hcd_ppc_soc_cleanup(void)
221{
222 platform_driver_unregister(&ohci_hcd_ppc_soc_driver);
223}
224
225module_init(ohci_hcd_ppc_soc_init);
226module_exit(ohci_hcd_ppc_soc_cleanup);
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c
index 3bbea844a9e3..f1563dc319d3 100644
--- a/drivers/usb/host/ohci-pxa27x.c
+++ b/drivers/usb/host/ohci-pxa27x.c
@@ -369,19 +369,3 @@ static struct platform_driver ohci_hcd_pxa27x_driver = {
369 }, 369 },
370}; 370};
371 371
372static int __init ohci_hcd_pxa27x_init (void)
373{
374 pr_debug (DRIVER_INFO " (pxa27x)");
375 pr_debug ("block sizes: ed %d td %d\n",
376 sizeof (struct ed), sizeof (struct td));
377
378 return platform_driver_register(&ohci_hcd_pxa27x_driver);
379}
380
381static void __exit ohci_hcd_pxa27x_cleanup (void)
382{
383 platform_driver_unregister(&ohci_hcd_pxa27x_driver);
384}
385
386module_init (ohci_hcd_pxa27x_init);
387module_exit (ohci_hcd_pxa27x_cleanup);
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c
index b350d45033e7..6829814b7aaf 100644
--- a/drivers/usb/host/ohci-s3c2410.c
+++ b/drivers/usb/host/ohci-s3c2410.c
@@ -501,15 +501,3 @@ static struct platform_driver ohci_hcd_s3c2410_driver = {
501 }, 501 },
502}; 502};
503 503
504static int __init ohci_hcd_s3c2410_init (void)
505{
506 return platform_driver_register(&ohci_hcd_s3c2410_driver);
507}
508
509static void __exit ohci_hcd_s3c2410_cleanup (void)
510{
511 platform_driver_unregister(&ohci_hcd_s3c2410_driver);
512}
513
514module_init (ohci_hcd_s3c2410_init);
515module_exit (ohci_hcd_s3c2410_cleanup);
diff --git a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c
index fe0090e33675..0f48f2d99226 100644
--- a/drivers/usb/host/ohci-sa1111.c
+++ b/drivers/usb/host/ohci-sa1111.c
@@ -269,19 +269,3 @@ static struct sa1111_driver ohci_hcd_sa1111_driver = {
269 .remove = ohci_hcd_sa1111_drv_remove, 269 .remove = ohci_hcd_sa1111_drv_remove,
270}; 270};
271 271
272static int __init ohci_hcd_sa1111_init (void)
273{
274 dbg (DRIVER_INFO " (SA-1111)");
275 dbg ("block sizes: ed %d td %d",
276 sizeof (struct ed), sizeof (struct td));
277
278 return sa1111_driver_register(&ohci_hcd_sa1111_driver);
279}
280
281static void __exit ohci_hcd_sa1111_cleanup (void)
282{
283 sa1111_driver_unregister(&ohci_hcd_sa1111_driver);
284}
285
286module_init (ohci_hcd_sa1111_init);
287module_exit (ohci_hcd_sa1111_cleanup);