]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
USB: EHCI: log a warning if ehci-hcd is not loaded first
authorAlan Stern <stern@rowland.harvard.edu>
Fri, 17 Oct 2008 23:10:07 +0000 (23:10 +0000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 22 Oct 2008 21:21:22 +0000 (14:21 -0700)
commit 9beeee6584b9aa4f9192055512411484a2a624df upstream

This patch (as1139) adds a warning to the system log whenever ehci-hcd
is loaded after ohci-hcd or uhci-hcd.  Nowadays most distributions are
pretty good about not doing this; maybe the warning will help convince
anyone still doing it wrong.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/core/hcd.c
drivers/usb/core/hcd.h
drivers/usb/host/ehci-hcd.c
drivers/usb/host/ohci-hcd.c
drivers/usb/host/uhci-hcd.c

index 8ab389dca2b91c49bfdb75e900a1c5a5dde3d334..706f3e6a07d5b6542a272e5ad45dd6d2ffb3c3e2 100644 (file)
 
 /*-------------------------------------------------------------------------*/
 
+/* Keep track of which host controller drivers are loaded */
+unsigned long usb_hcds_loaded;
+EXPORT_SYMBOL_GPL(usb_hcds_loaded);
+
 /* host controllers we manage */
 LIST_HEAD (usb_bus_list);
 EXPORT_SYMBOL_GPL (usb_bus_list);
index e710ce04e228f94647908d789500a4e2b8a646f9..2dcde61c465e0176d44a418cfdc038666556579c 100644 (file)
@@ -482,4 +482,10 @@ static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb,
  */
 extern struct rw_semaphore ehci_cf_port_reset_rwsem;
 
+/* Keep track of which host controller drivers are loaded */
+#define USB_UHCI_LOADED                0
+#define USB_OHCI_LOADED                1
+#define USB_EHCI_LOADED                2
+extern unsigned long usb_hcds_loaded;
+
 #endif /* __KERNEL__ */
index 8409e0705d6365c34e6db7252cc39eb60575877a..86e38b0569f61e97791634683f42c49d1c5b7da3 100644 (file)
@@ -1049,6 +1049,12 @@ static int __init ehci_hcd_init(void)
 {
        int retval = 0;
 
+       set_bit(USB_EHCI_LOADED, &usb_hcds_loaded);
+       if (test_bit(USB_UHCI_LOADED, &usb_hcds_loaded) ||
+                       test_bit(USB_OHCI_LOADED, &usb_hcds_loaded))
+               printk(KERN_WARNING "Warning! ehci_hcd should always be loaded"
+                               " before uhci_hcd and ohci_hcd, not after\n");
+
        pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
                 hcd_name,
                 sizeof(struct ehci_qh), sizeof(struct ehci_qtd),
@@ -1056,8 +1062,10 @@ static int __init ehci_hcd_init(void)
 
 #ifdef DEBUG
        ehci_debug_root = debugfs_create_dir("ehci", NULL);
-       if (!ehci_debug_root)
-               return -ENOENT;
+       if (!ehci_debug_root) {
+               retval = -ENOENT;
+               goto err_debug;
+       }
 #endif
 
 #ifdef PLATFORM_DRIVER
@@ -1104,7 +1112,9 @@ clean0:
 #ifdef DEBUG
        debugfs_remove(ehci_debug_root);
        ehci_debug_root = NULL;
+err_debug:
 #endif
+       clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded);
        return retval;
 }
 module_init(ehci_hcd_init);
@@ -1126,6 +1136,7 @@ static void __exit ehci_hcd_cleanup(void)
 #ifdef DEBUG
        debugfs_remove(ehci_debug_root);
 #endif
+       clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded);
 }
 module_exit(ehci_hcd_cleanup);
 
index 89901962cbfd821bc454353f61ed1e4e66ecf8db..8bec02c6736ea29664ec811a14e4ed06481c6759 100644 (file)
@@ -1098,6 +1098,7 @@ static int __init ohci_hcd_mod_init(void)
        printk (KERN_DEBUG "%s: " DRIVER_INFO "\n", hcd_name);
        pr_debug ("%s: block sizes: ed %Zd td %Zd\n", hcd_name,
                sizeof (struct ed), sizeof (struct td));
+       set_bit(USB_OHCI_LOADED, &usb_hcds_loaded);
 
 #ifdef DEBUG
        ohci_debug_root = debugfs_create_dir("ohci", NULL);
@@ -1184,6 +1185,7 @@ static int __init ohci_hcd_mod_init(void)
  error_debug:
 #endif
 
+       clear_bit(USB_OHCI_LOADED, &usb_hcds_loaded);
        return retval;
 }
 module_init(ohci_hcd_mod_init);
@@ -1214,6 +1216,7 @@ static void __exit ohci_hcd_mod_exit(void)
 #ifdef DEBUG
        debugfs_remove(ohci_debug_root);
 #endif
+       clear_bit(USB_OHCI_LOADED, &usb_hcds_loaded);
 }
 module_exit(ohci_hcd_mod_exit);
 
index 3a7bfe7a8874c321990bb802910ea4a902671c9a..59bed3c4259dc2d4916ba447074c1590d01ee98f 100644 (file)
@@ -953,6 +953,7 @@ static int __init uhci_hcd_init(void)
 
        printk(KERN_INFO DRIVER_DESC " " DRIVER_VERSION "%s\n",
                        ignore_oc ? ", overcurrent ignored" : "");
+       set_bit(USB_UHCI_LOADED, &usb_hcds_loaded);
 
        if (usb_disabled())
                return -ENODEV;
@@ -988,6 +989,7 @@ debug_failed:
 
 errbuf_failed:
 
+       clear_bit(USB_UHCI_LOADED, &usb_hcds_loaded);
        return retval;
 }
 
@@ -997,6 +999,7 @@ static void __exit uhci_hcd_cleanup(void)
        kmem_cache_destroy(uhci_up_cachep);
        debugfs_remove(uhci_debugfs_root);
        kfree(errbuf);
+       clear_bit(USB_UHCI_LOADED, &usb_hcds_loaded);
 }
 
 module_init(uhci_hcd_init);