Re: USB initialisation

From: Russell King (rmk@arm.linux.org.uk)
Date: Sat Aug 12 2000 - 14:38:08 EST


Linus Torvalds writes:
> On Sat, 12 Aug 2000, Russell King wrote:
> > However, the USB drivers (OHCI) are initialised before this time by
> > an explicit call in init/main.c.
> >
> > Can we initialise the USB hardware drivers via the initcall method,
> > or is there some reason why its done the way it is?
>
> I would _much_ prefer to have the USB drivers fully initialized with
> "initcalls()". The only reason it's done like it is right now is that I
> suspect the USB maintainers didn't realize that you can fully order the
> initcall sequence by just chaning the link order. If I get a patch that
> removes "usb_init()" from init/main.c, I'll apply it right away.

Here is the preliminary attempt - that is I don't have any USB hardware setup
that I can test this on, so its untested. I'd like some people to try it out,
especially the SA1100 guys who had the problem initally.

Linus, unless you think this is OK, I'd prefer people who have USB to test
this before it goes into the pre patches. (mind you, getting it in the
pre-patches is probably the best way of getting it tested). I'll leave this
up to your discression.

diff -ur orig/drivers/usb/Makefile linux/drivers/usb/Makefile
--- orig/drivers/usb/Makefile Thu Aug 10 20:46:21 2000
+++ linux/drivers/usb/Makefile Sat Aug 12 20:26:00 2000
@@ -37,27 +37,6 @@
 obj-n :=
 obj- :=
 
-# Object files in subdirectories
-
-ifeq ($(CONFIG_USB_SERIAL),y)
- SUB_DIRS += serial
- obj-y += serial/usb-serial.o
-else
- ifeq ($(CONFIG_USB_SERIAL),m)
- MOD_IN_SUB_DIRS += serial
- endif
-endif
-
-ifeq ($(CONFIG_USB_STORAGE),y)
- SUB_DIRS += storage
- obj-y += storage/usb-storage.o
-else
- ifeq ($(CONFIG_USB_STORAGE),m)
- MOD_IN_SUB_DIRS += storage
- endif
-endif
-
-
 # Each configuration option enables a list of files.
 
 obj-$(CONFIG_USB) += usbcore.o
@@ -92,6 +71,27 @@
 obj-$(CONFIG_USB_MICROTEK) += microtek.o
 obj-$(CONFIG_USB_BLUETOOTH) += bluetooth.o
 
+# Object files in subdirectories
+
+ifeq ($(CONFIG_USB_SERIAL),y)
+ SUB_DIRS += serial
+ obj-y += serial/usb-serial.o
+else
+ ifeq ($(CONFIG_USB_SERIAL),m)
+ MOD_IN_SUB_DIRS += serial
+ endif
+endif
+
+ifeq ($(CONFIG_USB_STORAGE),y)
+ SUB_DIRS += storage
+ obj-y += storage/usb-storage.o
+else
+ ifeq ($(CONFIG_USB_STORAGE),m)
+ MOD_IN_SUB_DIRS += storage
+ endif
+endif
+
+
 # Extract lists of the multi-part drivers.
 # The 'int-*' lists are the intermediate files used to build the multi's.
 
@@ -111,8 +111,8 @@
 
 # Translate to Rules.make lists.
 
-O_OBJS := $(sort $(filter-out $(export-objs), $(obj-y)))
-OX_OBJS := $(sort $(filter $(export-objs), $(obj-y)))
+O_OBJS := $(filter-out $(export-objs), $(obj-y))
+OX_OBJS := $(filter $(export-objs), $(obj-y))
 M_OBJS := $(sort $(filter-out $(export-objs), $(obj-m)))
 MX_OBJS := $(sort $(filter $(export-objs), $(obj-m)))
 MI_OBJS := $(sort $(filter-out $(export-objs), $(int-m)))
diff -ur orig/drivers/usb/usb-core.c linux/drivers/usb/usb-core.c
--- orig/drivers/usb/usb-core.c Tue May 30 23:51:22 2000
+++ linux/drivers/usb/usb-core.c Sat Aug 12 20:29:31 2000
@@ -13,6 +13,7 @@
 #include <linux/version.h>
 #include <linux/kernel.h>
 #include <linux/config.h>
+#include <linux/init.h>
 #include <linux/usb.h>
 
 /*
@@ -42,13 +43,11 @@
 int uhci_init(void);
 int ohci_hcd_init(void);
 
-#ifdef MODULE
-
 /*
  * Cleanup
  */
 
-void cleanup_module(void)
+static void __exit usb_exit(void)
 {
         usb_major_cleanup();
         usbdevfs_cleanup();
@@ -59,10 +58,7 @@
  * Init
  */
 
-int init_module(void)
-#else
-int usb_init(void)
-#endif
+static int __init usb_init(void)
 {
         usb_major_init();
         usbdevfs_init();
@@ -99,3 +95,6 @@
 #endif
         return 0;
 }
+
+module_init(usb_init);
+module_exit(usb_exit);

   _____
  |_____| ------------------------------------------------- ---+---+-
  | | Russell King rmk@arm.linux.org.uk --- ---
  | | | | http://www.arm.linux.org.uk/personal/aboutme.html / / |
  | +-+-+ --- -+-
  / | THE developer of ARM Linux |+| /|\
 / | | | --- |
    +-+-+ ------------------------------------------------- /\\\ |

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Aug 15 2000 - 21:00:28 EST