aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/ohci-hcd.c
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 /drivers/usb/host/ohci-hcd.c
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>
Diffstat (limited to 'drivers/usb/host/ohci-hcd.c')
-rw-r--r--drivers/usb/host/ohci-hcd.c92
1 files changed, 80 insertions, 12 deletions
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