c209ee035b117520663464b774d9f10ad79ecfe9
[openembedded.git] /
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
5
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.
11
12 The ohci-hcd.c file now provide the module_init & module_exit and
13 appropriate driver registering/unregistering is done conditionally,
14 using #ifdefs.
15
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>
19 ---
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(-)
34
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 = {
40         },
41  };
42  
43 -static int __init ohci_hcd_at91_init (void)
44 -{
45 -       if (usb_disabled())
46 -               return -ENODEV;
47 -
48 -       return platform_driver_register(&ohci_hcd_at91_driver);
49 -}
50 -
51 -static void __exit ohci_hcd_at91_cleanup (void)
52 -{
53 -       platform_driver_unregister(&ohci_hcd_at91_driver);
54 -}
55 -
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 = {
63         },
64  };
65  
66 -static int __init ohci_hcd_au1xxx_init (void)
67 -{
68 -       pr_debug (DRIVER_INFO " (Au1xxx)");
69 -       pr_debug ("block sizes: ed %d td %d\n",
70 -               sizeof (struct ed), sizeof (struct td));
71 -
72 -       return platform_driver_register(&ohci_hcd_au1xxx_driver);
73 -}
74 -
75 -static void __exit ohci_hcd_au1xxx_cleanup (void)
76 -{
77 -       platform_driver_unregister(&ohci_hcd_au1xxx_driver);
78 -}
79 -
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 = {
87         },
88  };
89  
90 -static int __init ohci_hcd_ep93xx_init(void)
91 -{
92 -       return platform_driver_register(&ohci_hcd_ep93xx_driver);
93 -}
94 -
95 -static void __exit ohci_hcd_ep93xx_cleanup(void)
96 -{
97 -       platform_driver_unregister(&ohci_hcd_ep93xx_driver);
98 -}
99 -
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");
107  
108  #ifdef CONFIG_PCI
109  #include "ohci-pci.c"
110 +#define PCI_DRIVER             ohci_pci_driver
111  #endif
112  
113  #ifdef CONFIG_SA1111
114  #include "ohci-sa1111.c"
115 +#define SA1111_DRIVER          ohci_hcd_sa1111_driver
116  #endif
117  
118  #ifdef CONFIG_ARCH_S3C2410
119  #include "ohci-s3c2410.c"
120 +#define PLATFORM_DRIVER                ohci_hcd_s3c2410_driver
121  #endif
122  
123  #ifdef CONFIG_ARCH_OMAP
124  #include "ohci-omap.c"
125 +#define PLATFORM_DRIVER                ohci_hcd_omap_driver
126  #endif
127  
128  #ifdef CONFIG_ARCH_LH7A404
129  #include "ohci-lh7a404.c"
130 +#define PLATFORM_DRIVER                ohci_hcd_lh7a404_driver
131  #endif
132  
133  #ifdef CONFIG_PXA27x
134  #include "ohci-pxa27x.c"
135 +#define PLATFORM_DRIVER                ohci_hcd_pxa27x_driver
136  #endif
137  
138  #ifdef CONFIG_ARCH_EP93XX
139  #include "ohci-ep93xx.c"
140 +#define PLATFORM_DRIVER                ohci_hcd_ep93xx_driver
141  #endif
142  
143  #ifdef CONFIG_SOC_AU1X00
144  #include "ohci-au1xxx.c"
145 +#define PLATFORM_DRIVER                ohci_hcd_au1xxx_driver
146  #endif
147  
148 -#ifdef CONFIG_PNX8550
149 -#include "ohci-pnx8550.c"
150 -#endif
151 +#ifdef CONFIG_PNX8550 
152 +#include "ohci-pnx8550.c" 
153 +#define PLATFORM_DRIVER                ohci_hcd_pnx8550_driver
154 +#endif 
155  
156  #ifdef CONFIG_USB_OHCI_HCD_PPC_SOC
157  #include "ohci-ppc-soc.c"
158 +#define PLATFORM_DRIVER                ohci_hcd_ppc_soc_driver
159  #endif
160  
161  #ifdef CONFIG_ARCH_AT91
162  #include "ohci-at91.c"
163 +#define PLATFORM_DRIVER                ohci_hcd_at91_driver
164  #endif
165  
166  #ifdef CONFIG_ARCH_PNX4008
167  #include "ohci-pnx4008.c"
168 +#define PLATFORM_DRIVER                usb_hcd_pnx4008_driver
169  #endif
170  
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) \
182 -       )
183 +
184 +#if    !defined(PCI_DRIVER) &&         \
185 +       !defined(PLATFORM_DRIVER) &&    \
186 +       !defined(SA1111_DRIVER)
187  #error "missing bus glue for ohci-hcd"
188  #endif
189 +
190 +static int __init ohci_hcd_mod_init(void)
191 +{
192 +       int retval = 0;
193 +       int ls = 0;
194 +
195 +       if (usb_disabled())
196 +               return -ENODEV;
197 +
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));
201 +
202 +#ifdef PLATFORM_DRIVER
203 +       retval = platform_driver_register(&PLATFORM_DRIVER);
204 +       if (retval < 0)
205 +               return retval;
206 +       ls++;
207 +#endif
208 +
209 +#ifdef SA1111_DRIVER
210 +       retval = sa1111_driver_register(&SA1111_DRIVER);
211 +       if (retval < 0)
212 +               goto error;
213 +       ls++;
214 +#endif
215 +
216 +#ifdef PCI_DRIVER
217 +       retval = pci_register_driver(&PCI_DRIVER);
218 +       if (retval < 0)
219 +               goto error;
220 +       ls++;
221 +#endif
222 +
223 +       return retval;
224 +
225 +       /* Error path */
226 +error:
227 +#ifdef PLATFORM_DRIVER
228 +       if (ls--)
229 +               platform_driver_unregister(&PLATFORM_DRIVER);
230 +#endif
231 +#ifdef SA1111_DRIVER
232 +       if (ls--)
233 +               sa1111_driver_unregister(&SA1111_DRIVER);
234 +#endif
235 +       return retval;
236 +}
237 +module_init(ohci_hcd_mod_init);
238 +
239 +static void __exit ohci_hcd_mod_exit(void)
240 +{
241 +#ifdef PCI_DRIVER
242 +       pci_unregister_driver(&PCI_DRIVER);
243 +#endif
244 +#ifdef SA1111_DRIVER
245 +       sa1111_driver_unregister(&SA1111_DRIVER);
246 +#endif
247 +#ifdef PLATFORM_DRIVER
248 +       platform_driver_unregister(&PLATFORM_DRIVER);
249 +#endif
250 +}
251 +module_exit(ohci_hcd_mod_exit);
252 +
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 = {
258         },
259  };
260  
261 -static int __init ohci_hcd_lh7a404_init (void)
262 -{
263 -       pr_debug (DRIVER_INFO " (LH7A404)");
264 -       pr_debug ("block sizes: ed %d td %d\n",
265 -               sizeof (struct ed), sizeof (struct td));
266 -
267 -       return platform_driver_register(&ohci_hcd_lh7a404_driver);
268 -}
269 -
270 -static void __exit ohci_hcd_lh7a404_cleanup (void)
271 -{
272 -       platform_driver_unregister(&ohci_hcd_lh7a404_driver);
273 -}
274 -
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 = {
282         },
283  };
284  
285 -static int __init ohci_hcd_omap_init (void)
286 -{
287 -       printk (KERN_DEBUG "%s: " DRIVER_INFO " (OMAP)\n", hcd_name);
288 -       if (usb_disabled())
289 -               return -ENODEV;
290 -
291 -       pr_debug("%s: block sizes: ed %Zd td %Zd\n", hcd_name,
292 -               sizeof (struct ed), sizeof (struct td));
293 -
294 -       return platform_driver_register(&ohci_hcd_omap_driver);
295 -}
296 -
297 -static void __exit ohci_hcd_omap_cleanup (void)
298 -{
299 -       platform_driver_unregister(&ohci_hcd_omap_driver);
300 -}
301 -
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,
310  };
311  
312 -
313 -static int __init ohci_hcd_pci_init (void)
314 -{
315 -       printk (KERN_DEBUG "%s: " DRIVER_INFO " (PCI)\n", hcd_name);
316 -       if (usb_disabled())
317 -               return -ENODEV;
318 -
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);
322 -}
323 -module_init (ohci_hcd_pci_init);
324 -
325 -/*-------------------------------------------------------------------------*/
326 -
327 -static void __exit ohci_hcd_pci_cleanup (void)
328 -{
329 -       pci_unregister_driver (&ohci_pci_driver);
330 -}
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,
338  };
339  
340 -static int __init usb_hcd_pnx4008_init(void)
341 -{
342 -       return platform_driver_register(&usb_hcd_pnx4008_driver);
343 -}
344 -
345 -static void __exit usb_hcd_pnx4008_cleanup(void)
346 -{
347 -       return platform_driver_unregister(&usb_hcd_pnx4008_driver);
348 -}
349 -
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,
358  };
359  
360 -static int __init ohci_hcd_pnx8550_init (void)
361 -{
362 -       pr_debug (DRIVER_INFO " (pnx8550)");
363 -       pr_debug ("block sizes: ed %d td %d\n",
364 -               sizeof (struct ed), sizeof (struct td));
365 -
366 -       return platform_driver_register(&ohci_hcd_pnx8550_driver);
367 -}
368 -
369 -static void __exit ohci_hcd_pnx8550_cleanup (void)
370 -{
371 -       platform_driver_unregister(&ohci_hcd_pnx8550_driver);
372 -}
373 -
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 = {
381         },
382  };
383  
384 -static int __init ohci_hcd_ppc_soc_init(void)
385 -{
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));
389 -
390 -       return platform_driver_register(&ohci_hcd_ppc_soc_driver);
391 -}
392 -
393 -static void __exit ohci_hcd_ppc_soc_cleanup(void)
394 -{
395 -       platform_driver_unregister(&ohci_hcd_ppc_soc_driver);
396 -}
397 -
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 = {
405         },
406  };
407  
408 -static int __init ohci_hcd_pxa27x_init (void)
409 -{
410 -       pr_debug (DRIVER_INFO " (pxa27x)");
411 -       pr_debug ("block sizes: ed %d td %d\n",
412 -               sizeof (struct ed), sizeof (struct td));
413 -
414 -       return platform_driver_register(&ohci_hcd_pxa27x_driver);
415 -}
416 -
417 -static void __exit ohci_hcd_pxa27x_cleanup (void)
418 -{
419 -       platform_driver_unregister(&ohci_hcd_pxa27x_driver);
420 -}
421 -
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 = {
429         },
430  };
431  
432 -static int __init ohci_hcd_s3c2410_init (void)
433 -{
434 -       return platform_driver_register(&ohci_hcd_s3c2410_driver);
435 -}
436 -
437 -static void __exit ohci_hcd_s3c2410_cleanup (void)
438 -{
439 -       platform_driver_unregister(&ohci_hcd_s3c2410_driver);
440 -}
441 -
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,
450  };
451  
452 -static int __init ohci_hcd_sa1111_init (void)
453 -{
454 -       dbg (DRIVER_INFO " (SA-1111)");
455 -       dbg ("block sizes: ed %d td %d",
456 -               sizeof (struct ed), sizeof (struct td));
457 -
458 -       return sa1111_driver_register(&ohci_hcd_sa1111_driver);
459 -}
460 -
461 -static void __exit ohci_hcd_sa1111_cleanup (void)
462 -{
463 -       sa1111_driver_unregister(&ohci_hcd_sa1111_driver);
464 -}
465 -
466 -module_init (ohci_hcd_sa1111_init);
467 -module_exit (ohci_hcd_sa1111_cleanup);
468 -- 
469 1.4.4.2
470