Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Sylvain Munaut and committed by
Greg Kroah-Hartman
5e16fabe ad55d71a

+80 -198
-15
drivers/usb/host/ohci-at91.c
··· 320 320 }, 321 321 }; 322 322 323 - static 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 - 331 - static void __exit ohci_hcd_at91_cleanup (void) 332 - { 333 - platform_driver_unregister(&ohci_hcd_at91_driver); 334 - } 335 - 336 - module_init (ohci_hcd_at91_init); 337 - module_exit (ohci_hcd_at91_cleanup);
-16
drivers/usb/host/ohci-au1xxx.c
··· 345 345 }, 346 346 }; 347 347 348 - static 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 - 357 - static void __exit ohci_hcd_au1xxx_cleanup (void) 358 - { 359 - platform_driver_unregister(&ohci_hcd_au1xxx_driver); 360 - } 361 - 362 - module_init (ohci_hcd_au1xxx_init); 363 - module_exit (ohci_hcd_au1xxx_cleanup);
-12
drivers/usb/host/ohci-ep93xx.c
··· 214 214 }, 215 215 }; 216 216 217 - static int __init ohci_hcd_ep93xx_init(void) 218 - { 219 - return platform_driver_register(&ohci_hcd_ep93xx_driver); 220 - } 221 - 222 - static void __exit ohci_hcd_ep93xx_cleanup(void) 223 - { 224 - platform_driver_unregister(&ohci_hcd_ep93xx_driver); 225 - } 226 - 227 - module_init(ohci_hcd_ep93xx_init); 228 - module_exit(ohci_hcd_ep93xx_cleanup);
+80 -12
drivers/usb/host/ohci-hcd.c
··· 855 855 856 856 #ifdef CONFIG_PCI 857 857 #include "ohci-pci.c" 858 + #define PCI_DRIVER ohci_pci_driver 858 859 #endif 859 860 860 861 #ifdef CONFIG_SA1111 861 862 #include "ohci-sa1111.c" 863 + #define SA1111_DRIVER ohci_hcd_sa1111_driver 862 864 #endif 863 865 864 866 #ifdef CONFIG_ARCH_S3C2410 865 867 #include "ohci-s3c2410.c" 868 + #define PLATFORM_DRIVER ohci_hcd_s3c2410_driver 866 869 #endif 867 870 868 871 #ifdef CONFIG_ARCH_OMAP 869 872 #include "ohci-omap.c" 873 + #define PLATFORM_DRIVER ohci_hcd_omap_driver 870 874 #endif 871 875 872 876 #ifdef CONFIG_ARCH_LH7A404 873 877 #include "ohci-lh7a404.c" 878 + #define PLATFORM_DRIVER ohci_hcd_lh7a404_driver 874 879 #endif 875 880 876 881 #ifdef CONFIG_PXA27x 877 882 #include "ohci-pxa27x.c" 883 + #define PLATFORM_DRIVER ohci_hcd_pxa27x_driver 878 884 #endif 879 885 880 886 #ifdef CONFIG_ARCH_EP93XX 881 887 #include "ohci-ep93xx.c" 888 + #define PLATFORM_DRIVER ohci_hcd_ep93xx_driver 882 889 #endif 883 890 884 891 #ifdef CONFIG_SOC_AU1X00 885 892 #include "ohci-au1xxx.c" 893 + #define PLATFORM_DRIVER ohci_hcd_au1xxx_driver 886 894 #endif 887 895 888 896 #ifdef CONFIG_PNX8550 889 897 #include "ohci-pnx8550.c" 898 + #define PLATFORM_DRIVER ohci_hcd_pnx8550_driver 890 899 #endif 891 900 892 901 #ifdef CONFIG_USB_OHCI_HCD_PPC_SOC 893 902 #include "ohci-ppc-soc.c" 903 + #define PLATFORM_DRIVER ohci_hcd_ppc_soc_driver 894 904 #endif 895 905 896 906 #ifdef CONFIG_ARCH_AT91 897 907 #include "ohci-at91.c" 908 + #define PLATFORM_DRIVER ohci_hcd_at91_driver 898 909 #endif 899 910 900 911 #ifdef CONFIG_ARCH_PNX4008 901 912 #include "ohci-pnx4008.c" 913 + #define PLATFORM_DRIVER usb_hcd_pnx4008_driver 902 914 #endif 903 915 904 - #if !(defined(CONFIG_PCI) \ 905 - || defined(CONFIG_SA1111) \ 906 - || defined(CONFIG_ARCH_S3C2410) \ 907 - || defined(CONFIG_ARCH_OMAP) \ 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 + 917 + #if !defined(PCI_DRIVER) && \ 918 + !defined(PLATFORM_DRIVER) && \ 919 + !defined(SA1111_DRIVER) 916 920 #error "missing bus glue for ohci-hcd" 917 921 #endif 922 + 923 + static 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 */ 959 + error: 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 + } 970 + module_init(ohci_hcd_mod_init); 971 + 972 + static 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 + } 984 + module_exit(ohci_hcd_mod_exit); 985 +
-16
drivers/usb/host/ohci-lh7a404.c
··· 251 251 }, 252 252 }; 253 253 254 - static 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 - 263 - static void __exit ohci_hcd_lh7a404_cleanup (void) 264 - { 265 - platform_driver_unregister(&ohci_hcd_lh7a404_driver); 266 - } 267 - 268 - module_init (ohci_hcd_lh7a404_init); 269 - module_exit (ohci_hcd_lh7a404_cleanup);
-19
drivers/usb/host/ohci-omap.c
··· 544 544 }, 545 545 }; 546 546 547 - static 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 - 559 - static void __exit ohci_hcd_omap_cleanup (void) 560 - { 561 - platform_driver_unregister(&ohci_hcd_omap_driver); 562 - } 563 - 564 - module_init (ohci_hcd_omap_init); 565 - module_exit (ohci_hcd_omap_cleanup);
-20
drivers/usb/host/ohci-pci.c
··· 311 311 .shutdown = usb_hcd_pci_shutdown, 312 312 }; 313 313 314 - 315 - static 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 - } 325 - module_init (ohci_hcd_pci_init); 326 - 327 - /*-------------------------------------------------------------------------*/ 328 - 329 - static void __exit ohci_hcd_pci_cleanup (void) 330 - { 331 - pci_unregister_driver (&ohci_pci_driver); 332 - } 333 - module_exit (ohci_hcd_pci_cleanup);
-12
drivers/usb/host/ohci-pnx4008.c
··· 465 465 .remove = usb_hcd_pnx4008_remove, 466 466 }; 467 467 468 - static int __init usb_hcd_pnx4008_init(void) 469 - { 470 - return platform_driver_register(&usb_hcd_pnx4008_driver); 471 - } 472 - 473 - static void __exit usb_hcd_pnx4008_cleanup(void) 474 - { 475 - return platform_driver_unregister(&usb_hcd_pnx4008_driver); 476 - } 477 - 478 - module_init(usb_hcd_pnx4008_init); 479 - module_exit(usb_hcd_pnx4008_cleanup);
-16
drivers/usb/host/ohci-pnx8550.c
··· 240 240 .remove = ohci_hcd_pnx8550_drv_remove, 241 241 }; 242 242 243 - static 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 - 252 - static void __exit ohci_hcd_pnx8550_cleanup (void) 253 - { 254 - platform_driver_unregister(&ohci_hcd_pnx8550_driver); 255 - } 256 - 257 - module_init (ohci_hcd_pnx8550_init); 258 - module_exit (ohci_hcd_pnx8550_cleanup);
-16
drivers/usb/host/ohci-ppc-soc.c
··· 208 208 }, 209 209 }; 210 210 211 - static 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 - 220 - static void __exit ohci_hcd_ppc_soc_cleanup(void) 221 - { 222 - platform_driver_unregister(&ohci_hcd_ppc_soc_driver); 223 - } 224 - 225 - module_init(ohci_hcd_ppc_soc_init); 226 - module_exit(ohci_hcd_ppc_soc_cleanup);
-16
drivers/usb/host/ohci-pxa27x.c
··· 369 369 }, 370 370 }; 371 371 372 - static 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 - 381 - static void __exit ohci_hcd_pxa27x_cleanup (void) 382 - { 383 - platform_driver_unregister(&ohci_hcd_pxa27x_driver); 384 - } 385 - 386 - module_init (ohci_hcd_pxa27x_init); 387 - module_exit (ohci_hcd_pxa27x_cleanup);
-12
drivers/usb/host/ohci-s3c2410.c
··· 501 501 }, 502 502 }; 503 503 504 - static int __init ohci_hcd_s3c2410_init (void) 505 - { 506 - return platform_driver_register(&ohci_hcd_s3c2410_driver); 507 - } 508 - 509 - static void __exit ohci_hcd_s3c2410_cleanup (void) 510 - { 511 - platform_driver_unregister(&ohci_hcd_s3c2410_driver); 512 - } 513 - 514 - module_init (ohci_hcd_s3c2410_init); 515 - module_exit (ohci_hcd_s3c2410_cleanup);
-16
drivers/usb/host/ohci-sa1111.c
··· 269 269 .remove = ohci_hcd_sa1111_drv_remove, 270 270 }; 271 271 272 - static 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 - 281 - static void __exit ohci_hcd_sa1111_cleanup (void) 282 - { 283 - sa1111_driver_unregister(&ohci_hcd_sa1111_driver); 284 - } 285 - 286 - module_init (ohci_hcd_sa1111_init); 287 - module_exit (ohci_hcd_sa1111_cleanup);