1 From 51294aa1482ea961a3e51ddac587b70b7c1c8ba0 Mon Sep 17 00:00:00 2001
2 From: Sylvain Munaut <tnt@246tNt.com>
3 Date: Wed, 13 Dec 2006 20:35:37 +0100
4 Subject: [PATCH] [PATCH] ohci: Rework bus glue integration to allow several at once
6 The previous model had the module_init & module_exit function in the
7 bus glue .c files themselves. That's a problem if several glues need
8 to be selected at once and the driver is built has module. This case
9 is quite common in embedded system where you want to handle both the
10 integrated ohci controller and some extra controller on PCI.
12 The ohci-hcd.c file now provide the module_init & module_exit and
13 appropriate driver registering/unregistering is done conditionally,
16 Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
17 Acked-by: David Brownell <dbrownell@users.sourceforge.net>
18 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
20 drivers/usb/host/ohci-at91.c | 15 ------
21 drivers/usb/host/ohci-au1xxx.c | 16 ------
22 drivers/usb/host/ohci-ep93xx.c | 12 -----
23 drivers/usb/host/ohci-hcd.c | 98 +++++++++++++++++++++++++++++++++------
24 drivers/usb/host/ohci-lh7a404.c | 16 ------
25 drivers/usb/host/ohci-omap.c | 19 --------
26 drivers/usb/host/ohci-pci.c | 20 --------
27 drivers/usb/host/ohci-pnx4008.c | 12 -----
28 drivers/usb/host/ohci-pnx8550.c | 16 ------
29 drivers/usb/host/ohci-ppc-soc.c | 16 ------
30 drivers/usb/host/ohci-pxa27x.c | 16 ------
31 drivers/usb/host/ohci-s3c2410.c | 12 -----
32 drivers/usb/host/ohci-sa1111.c | 16 ------
33 13 files changed, 83 insertions(+), 201 deletions(-)
35 diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
36 index cc40551..53f62cf 100644
37 --- a/drivers/usb/host/ohci-at91.c
38 +++ b/drivers/usb/host/ohci-at91.c
39 @@ -320,18 +320,3 @@ static struct platform_driver ohci_hcd_at91_driver = {
43 -static int __init ohci_hcd_at91_init (void)
48 - return platform_driver_register(&ohci_hcd_at91_driver);
51 -static void __exit ohci_hcd_at91_cleanup (void)
53 - platform_driver_unregister(&ohci_hcd_at91_driver);
56 -module_init (ohci_hcd_at91_init);
57 -module_exit (ohci_hcd_at91_cleanup);
58 diff --git a/drivers/usb/host/ohci-au1xxx.c b/drivers/usb/host/ohci-au1xxx.c
59 index e70b243..663a060 100644
60 --- a/drivers/usb/host/ohci-au1xxx.c
61 +++ b/drivers/usb/host/ohci-au1xxx.c
62 @@ -345,19 +345,3 @@ static struct platform_driver ohci_hcd_au1xxx_driver = {
66 -static int __init ohci_hcd_au1xxx_init (void)
68 - pr_debug (DRIVER_INFO " (Au1xxx)");
69 - pr_debug ("block sizes: ed %d td %d\n",
70 - sizeof (struct ed), sizeof (struct td));
72 - return platform_driver_register(&ohci_hcd_au1xxx_driver);
75 -static void __exit ohci_hcd_au1xxx_cleanup (void)
77 - platform_driver_unregister(&ohci_hcd_au1xxx_driver);
80 -module_init (ohci_hcd_au1xxx_init);
81 -module_exit (ohci_hcd_au1xxx_cleanup);
82 diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c
83 index 43ae696..e9974c3 100644
84 --- a/drivers/usb/host/ohci-ep93xx.c
85 +++ b/drivers/usb/host/ohci-ep93xx.c
86 @@ -214,15 +214,3 @@ static struct platform_driver ohci_hcd_ep93xx_driver = {
90 -static int __init ohci_hcd_ep93xx_init(void)
92 - return platform_driver_register(&ohci_hcd_ep93xx_driver);
95 -static void __exit ohci_hcd_ep93xx_cleanup(void)
97 - platform_driver_unregister(&ohci_hcd_ep93xx_driver);
100 -module_init(ohci_hcd_ep93xx_init);
101 -module_exit(ohci_hcd_ep93xx_cleanup);
102 diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
103 index c1c1d87..9926b8f 100644
104 --- a/drivers/usb/host/ohci-hcd.c
105 +++ b/drivers/usb/host/ohci-hcd.c
106 @@ -855,63 +855,131 @@ MODULE_LICENSE ("GPL");
109 #include "ohci-pci.c"
110 +#define PCI_DRIVER ohci_pci_driver
114 #include "ohci-sa1111.c"
115 +#define SA1111_DRIVER ohci_hcd_sa1111_driver
118 #ifdef CONFIG_ARCH_S3C2410
119 #include "ohci-s3c2410.c"
120 +#define PLATFORM_DRIVER ohci_hcd_s3c2410_driver
123 #ifdef CONFIG_ARCH_OMAP
124 #include "ohci-omap.c"
125 +#define PLATFORM_DRIVER ohci_hcd_omap_driver
128 #ifdef CONFIG_ARCH_LH7A404
129 #include "ohci-lh7a404.c"
130 +#define PLATFORM_DRIVER ohci_hcd_lh7a404_driver
134 #include "ohci-pxa27x.c"
135 +#define PLATFORM_DRIVER ohci_hcd_pxa27x_driver
138 #ifdef CONFIG_ARCH_EP93XX
139 #include "ohci-ep93xx.c"
140 +#define PLATFORM_DRIVER ohci_hcd_ep93xx_driver
143 #ifdef CONFIG_SOC_AU1X00
144 #include "ohci-au1xxx.c"
145 +#define PLATFORM_DRIVER ohci_hcd_au1xxx_driver
148 -#ifdef CONFIG_PNX8550
149 -#include "ohci-pnx8550.c"
151 +#ifdef CONFIG_PNX8550
152 +#include "ohci-pnx8550.c"
153 +#define PLATFORM_DRIVER ohci_hcd_pnx8550_driver
156 #ifdef CONFIG_USB_OHCI_HCD_PPC_SOC
157 #include "ohci-ppc-soc.c"
158 +#define PLATFORM_DRIVER ohci_hcd_ppc_soc_driver
161 #ifdef CONFIG_ARCH_AT91
162 #include "ohci-at91.c"
163 +#define PLATFORM_DRIVER ohci_hcd_at91_driver
166 #ifdef CONFIG_ARCH_PNX4008
167 #include "ohci-pnx4008.c"
168 +#define PLATFORM_DRIVER usb_hcd_pnx4008_driver
171 -#if !(defined(CONFIG_PCI) \
172 - || defined(CONFIG_SA1111) \
173 - || defined(CONFIG_ARCH_S3C2410) \
174 - || defined(CONFIG_ARCH_OMAP) \
175 - || defined (CONFIG_ARCH_LH7A404) \
176 - || defined (CONFIG_PXA27x) \
177 - || defined (CONFIG_ARCH_EP93XX) \
178 - || defined (CONFIG_SOC_AU1X00) \
179 - || defined (CONFIG_USB_OHCI_HCD_PPC_SOC) \
180 - || defined (CONFIG_ARCH_AT91) \
181 - || defined (CONFIG_ARCH_PNX4008) \
184 +#if !defined(PCI_DRIVER) && \
185 + !defined(PLATFORM_DRIVER) && \
186 + !defined(SA1111_DRIVER)
187 #error "missing bus glue for ohci-hcd"
190 +static int __init ohci_hcd_mod_init(void)
195 + if (usb_disabled())
198 + printk (KERN_DEBUG "%s: " DRIVER_INFO "\n", hcd_name);
199 + pr_debug ("%s: block sizes: ed %Zd td %Zd\n", hcd_name,
200 + sizeof (struct ed), sizeof (struct td));
202 +#ifdef PLATFORM_DRIVER
203 + retval = platform_driver_register(&PLATFORM_DRIVER);
209 +#ifdef SA1111_DRIVER
210 + retval = sa1111_driver_register(&SA1111_DRIVER);
217 + retval = pci_register_driver(&PCI_DRIVER);
227 +#ifdef PLATFORM_DRIVER
229 + platform_driver_unregister(&PLATFORM_DRIVER);
231 +#ifdef SA1111_DRIVER
233 + sa1111_driver_unregister(&SA1111_DRIVER);
237 +module_init(ohci_hcd_mod_init);
239 +static void __exit ohci_hcd_mod_exit(void)
242 + pci_unregister_driver(&PCI_DRIVER);
244 +#ifdef SA1111_DRIVER
245 + sa1111_driver_unregister(&SA1111_DRIVER);
247 +#ifdef PLATFORM_DRIVER
248 + platform_driver_unregister(&PLATFORM_DRIVER);
251 +module_exit(ohci_hcd_mod_exit);
253 diff --git a/drivers/usb/host/ohci-lh7a404.c b/drivers/usb/host/ohci-lh7a404.c
254 index e9807cf..4a043ab 100644
255 --- a/drivers/usb/host/ohci-lh7a404.c
256 +++ b/drivers/usb/host/ohci-lh7a404.c
257 @@ -251,19 +251,3 @@ static struct platform_driver ohci_hcd_lh7a404_driver = {
261 -static int __init ohci_hcd_lh7a404_init (void)
263 - pr_debug (DRIVER_INFO " (LH7A404)");
264 - pr_debug ("block sizes: ed %d td %d\n",
265 - sizeof (struct ed), sizeof (struct td));
267 - return platform_driver_register(&ohci_hcd_lh7a404_driver);
270 -static void __exit ohci_hcd_lh7a404_cleanup (void)
272 - platform_driver_unregister(&ohci_hcd_lh7a404_driver);
275 -module_init (ohci_hcd_lh7a404_init);
276 -module_exit (ohci_hcd_lh7a404_cleanup);
277 diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
278 index 27be1f9..5cfa3d1 100644
279 --- a/drivers/usb/host/ohci-omap.c
280 +++ b/drivers/usb/host/ohci-omap.c
281 @@ -544,22 +544,3 @@ static struct platform_driver ohci_hcd_omap_driver = {
285 -static int __init ohci_hcd_omap_init (void)
287 - printk (KERN_DEBUG "%s: " DRIVER_INFO " (OMAP)\n", hcd_name);
288 - if (usb_disabled())
291 - pr_debug("%s: block sizes: ed %Zd td %Zd\n", hcd_name,
292 - sizeof (struct ed), sizeof (struct td));
294 - return platform_driver_register(&ohci_hcd_omap_driver);
297 -static void __exit ohci_hcd_omap_cleanup (void)
299 - platform_driver_unregister(&ohci_hcd_omap_driver);
302 -module_init (ohci_hcd_omap_init);
303 -module_exit (ohci_hcd_omap_cleanup);
304 diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
305 index 292daf0..b331ac4 100644
306 --- a/drivers/usb/host/ohci-pci.c
307 +++ b/drivers/usb/host/ohci-pci.c
308 @@ -311,23 +311,3 @@ static struct pci_driver ohci_pci_driver = {
309 .shutdown = usb_hcd_pci_shutdown,
313 -static int __init ohci_hcd_pci_init (void)
315 - printk (KERN_DEBUG "%s: " DRIVER_INFO " (PCI)\n", hcd_name);
316 - if (usb_disabled())
319 - pr_debug ("%s: block sizes: ed %Zd td %Zd\n", hcd_name,
320 - sizeof (struct ed), sizeof (struct td));
321 - return pci_register_driver (&ohci_pci_driver);
323 -module_init (ohci_hcd_pci_init);
325 -/*-------------------------------------------------------------------------*/
327 -static void __exit ohci_hcd_pci_cleanup (void)
329 - pci_unregister_driver (&ohci_pci_driver);
331 -module_exit (ohci_hcd_pci_cleanup);
332 diff --git a/drivers/usb/host/ohci-pnx4008.c b/drivers/usb/host/ohci-pnx4008.c
333 index 3a8cbfb..893b172 100644
334 --- a/drivers/usb/host/ohci-pnx4008.c
335 +++ b/drivers/usb/host/ohci-pnx4008.c
336 @@ -465,15 +465,3 @@ static struct platform_driver usb_hcd_pnx4008_driver = {
337 .remove = usb_hcd_pnx4008_remove,
340 -static int __init usb_hcd_pnx4008_init(void)
342 - return platform_driver_register(&usb_hcd_pnx4008_driver);
345 -static void __exit usb_hcd_pnx4008_cleanup(void)
347 - return platform_driver_unregister(&usb_hcd_pnx4008_driver);
350 -module_init(usb_hcd_pnx4008_init);
351 -module_exit(usb_hcd_pnx4008_cleanup);
352 diff --git a/drivers/usb/host/ohci-pnx8550.c b/drivers/usb/host/ohci-pnx8550.c
353 index 6922b91..de45eb0 100644
354 --- a/drivers/usb/host/ohci-pnx8550.c
355 +++ b/drivers/usb/host/ohci-pnx8550.c
356 @@ -240,19 +240,3 @@ static struct platform_driver ohci_hcd_pnx8550_driver = {
357 .remove = ohci_hcd_pnx8550_drv_remove,
360 -static int __init ohci_hcd_pnx8550_init (void)
362 - pr_debug (DRIVER_INFO " (pnx8550)");
363 - pr_debug ("block sizes: ed %d td %d\n",
364 - sizeof (struct ed), sizeof (struct td));
366 - return platform_driver_register(&ohci_hcd_pnx8550_driver);
369 -static void __exit ohci_hcd_pnx8550_cleanup (void)
371 - platform_driver_unregister(&ohci_hcd_pnx8550_driver);
374 -module_init (ohci_hcd_pnx8550_init);
375 -module_exit (ohci_hcd_pnx8550_cleanup);
376 diff --git a/drivers/usb/host/ohci-ppc-soc.c b/drivers/usb/host/ohci-ppc-soc.c
377 index c7ce8e6..1a2e177 100644
378 --- a/drivers/usb/host/ohci-ppc-soc.c
379 +++ b/drivers/usb/host/ohci-ppc-soc.c
380 @@ -208,19 +208,3 @@ static struct platform_driver ohci_hcd_ppc_soc_driver = {
384 -static int __init ohci_hcd_ppc_soc_init(void)
386 - pr_debug(DRIVER_INFO " (PPC SOC)\n");
387 - pr_debug("block sizes: ed %d td %d\n", sizeof(struct ed),
388 - sizeof(struct td));
390 - return platform_driver_register(&ohci_hcd_ppc_soc_driver);
393 -static void __exit ohci_hcd_ppc_soc_cleanup(void)
395 - platform_driver_unregister(&ohci_hcd_ppc_soc_driver);
398 -module_init(ohci_hcd_ppc_soc_init);
399 -module_exit(ohci_hcd_ppc_soc_cleanup);
400 diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c
401 index 3bbea84..f1563dc 100644
402 --- a/drivers/usb/host/ohci-pxa27x.c
403 +++ b/drivers/usb/host/ohci-pxa27x.c
404 @@ -369,19 +369,3 @@ static struct platform_driver ohci_hcd_pxa27x_driver = {
408 -static int __init ohci_hcd_pxa27x_init (void)
410 - pr_debug (DRIVER_INFO " (pxa27x)");
411 - pr_debug ("block sizes: ed %d td %d\n",
412 - sizeof (struct ed), sizeof (struct td));
414 - return platform_driver_register(&ohci_hcd_pxa27x_driver);
417 -static void __exit ohci_hcd_pxa27x_cleanup (void)
419 - platform_driver_unregister(&ohci_hcd_pxa27x_driver);
422 -module_init (ohci_hcd_pxa27x_init);
423 -module_exit (ohci_hcd_pxa27x_cleanup);
424 diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c
425 index b350d45..6829814 100644
426 --- a/drivers/usb/host/ohci-s3c2410.c
427 +++ b/drivers/usb/host/ohci-s3c2410.c
428 @@ -501,15 +501,3 @@ static struct platform_driver ohci_hcd_s3c2410_driver = {
432 -static int __init ohci_hcd_s3c2410_init (void)
434 - return platform_driver_register(&ohci_hcd_s3c2410_driver);
437 -static void __exit ohci_hcd_s3c2410_cleanup (void)
439 - platform_driver_unregister(&ohci_hcd_s3c2410_driver);
442 -module_init (ohci_hcd_s3c2410_init);
443 -module_exit (ohci_hcd_s3c2410_cleanup);
444 diff --git a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c
445 index fe0090e..0f48f2d 100644
446 --- a/drivers/usb/host/ohci-sa1111.c
447 +++ b/drivers/usb/host/ohci-sa1111.c
448 @@ -269,19 +269,3 @@ static struct sa1111_driver ohci_hcd_sa1111_driver = {
449 .remove = ohci_hcd_sa1111_drv_remove,
452 -static int __init ohci_hcd_sa1111_init (void)
454 - dbg (DRIVER_INFO " (SA-1111)");
455 - dbg ("block sizes: ed %d td %d",
456 - sizeof (struct ed), sizeof (struct td));
458 - return sa1111_driver_register(&ohci_hcd_sa1111_driver);
461 -static void __exit ohci_hcd_sa1111_cleanup (void)
463 - sa1111_driver_unregister(&ohci_hcd_sa1111_driver);
466 -module_init (ohci_hcd_sa1111_init);
467 -module_exit (ohci_hcd_sa1111_cleanup);