]> git.hungrycats.org Git - linux/commitdiff
driver model: Make initialization explicit.
authorPatrick Mochel <mochel@osdl.org>
Tue, 4 Mar 2003 04:13:44 +0000 (22:13 -0600)
committerPatrick Mochel <mochel@osdl.org>
Tue, 4 Mar 2003 04:13:44 +0000 (22:13 -0600)
- Call driver_init() from init/main.c::do_basic_setup().

This ensures that all the driver model subsystems are initialized before
any drivers or devices can be registered.

It nearly frees up the core and postcore initcall levels, making them
available for other kernel code to use freely.

drivers/base/Makefile
drivers/base/bus.c
drivers/base/class.c
drivers/base/core.c
drivers/base/cpu.c
drivers/base/firmware.c
drivers/base/init.c [new file with mode: 0644]
drivers/base/sys.c
init/main.c

index 3b4aa06f8a03144a99118a9a65f6cb3070e53c0b..e9c753888d4812f6666241f449decf3aa0359c52 100644 (file)
@@ -2,7 +2,7 @@
 
 obj-y                  := core.o sys.o interface.o power.o bus.o \
                           driver.o class.o intf.o platform.o \
-                          cpu.o firmware.o
+                          cpu.o firmware.o init.o
 obj-$(CONFIG_NUMA)     += node.o  memblk.o
 obj-y                  += fs/
 obj-$(CONFIG_HOTPLUG)  += hotplug.o
index c0b46bb3eef055da25b857e3e6d0f4d3c013e3c8..d895085ea9da523e78f6699c020d797b87b86442 100644 (file)
@@ -544,12 +544,11 @@ void bus_unregister(struct bus_type * bus)
        subsystem_unregister(&bus->subsys);
 }
 
-static int __init bus_subsys_init(void)
+int __init buses_init(void)
 {
        return subsystem_register(&bus_subsys);
 }
 
-core_initcall(bus_subsys_init);
 
 EXPORT_SYMBOL(bus_for_each_dev);
 EXPORT_SYMBOL(bus_for_each_drv);
index cf8260017f2351b6f0e6f5dd6bf9168ba62d8b35..9007e99c0d7317f75f8f75bb30ba921268efdeb8 100644 (file)
@@ -266,13 +266,11 @@ void devclass_unregister(struct device_class * cls)
        subsystem_unregister(&cls->subsys);
 }
 
-static int __init class_subsys_init(void)
+int __init classes_init(void)
 {
        return subsystem_register(&class_subsys);
 }
 
-core_initcall(class_subsys_init);
-
 EXPORT_SYMBOL(devclass_create_file);
 EXPORT_SYMBOL(devclass_remove_file);
 EXPORT_SYMBOL(devclass_register);
index e37311995422cb71f6193981964b7ecc898eeb52..5f95879b80f211d493f88709fc0fb4fd5eac7ba1 100644 (file)
@@ -309,13 +309,11 @@ void device_unregister(struct device * dev)
        put_device(dev);
 }
 
-static int __init device_subsys_init(void)
+int __init devices_init(void)
 {
        return subsystem_register(&devices_subsys);
 }
 
-core_initcall(device_subsys_init);
-
 EXPORT_SYMBOL(device_initialize);
 EXPORT_SYMBOL(device_add);
 EXPORT_SYMBOL(device_register);
index 1c729154c10cba5e95e4919ecf6a43dcaf459f33..f815ef26e8e7c7f299c0832d1b04969e15732657 100644 (file)
@@ -46,9 +46,8 @@ int __init register_cpu(struct cpu *cpu, int num, struct node *root)
 }
 
 
-static int __init register_cpu_type(void)
+int __init cpu_dev_init(void)
 {
        devclass_register(&cpu_devclass);
        return driver_register(&cpu_driver);
 }
-postcore_initcall(register_cpu_type);
index eb0c09bfeea9e736017a5e43d01d75942807d7df..d6ddcd338528b5ffef42b5f51c3fb199ac7deb85 100644 (file)
@@ -19,12 +19,10 @@ void firmware_unregister(struct subsystem * s)
        subsystem_unregister(s);
 }
 
-static int __init firmware_init(void)
+int __init firmware_init(void)
 {
        return subsystem_register(&firmware_subsys);
 }
 
-core_initcall(firmware_init);
-
 EXPORT_SYMBOL(firmware_register);
 EXPORT_SYMBOL(firmware_unregister);
diff --git a/drivers/base/init.c b/drivers/base/init.c
new file mode 100644 (file)
index 0000000..e3739cd
--- /dev/null
@@ -0,0 +1,32 @@
+
+#include <linux/device.h>
+#include <linux/init.h>
+
+extern int devices_init(void);
+extern int buses_init(void);
+extern int classes_init(void);
+extern int firmware_init(void);
+extern int sys_bus_init(void);
+extern int cpu_dev_init(void);
+
+/**
+ *     driver_init - initialize driver model.
+ *
+ *     Call the driver model init functions to initialize their
+ *     subsystems. Called early from init/main.c.
+ */
+
+void __init driver_init(void)
+{
+       /* These are the core pieces */
+       devices_init();
+       buses_init();
+       classes_init();
+       firmware_init();
+
+       /* These are also core pieces, but must come after the 
+        * core core pieces.
+        */
+       sys_bus_init();
+       cpu_dev_init();
+}
index aa085a12d1e4237e6d7c81fe98c3605e976e0233..2d89725374619cac5c6d0e9e2a8e2cfe96e57026 100644 (file)
@@ -138,13 +138,12 @@ struct bus_type system_bus_type = {
        .name           = "system",
 };
 
-static int sys_bus_init(void)
+int __init sys_bus_init(void)
 {
        bus_register(&system_bus_type);
        return device_register(&system_bus);
 }
 
-postcore_initcall(sys_bus_init);
 EXPORT_SYMBOL(system_bus_type);
 EXPORT_SYMBOL(sys_device_register);
 EXPORT_SYMBOL(sys_device_unregister);
index 493e3715830ba853c60d58e9d2f353e088bdda5b..f885a1f785a6be9d92876e38f6b9000a8d2a80d8 100644 (file)
@@ -71,6 +71,7 @@ extern void pte_chain_init(void);
 extern void radix_tree_init(void);
 extern void free_initmem(void);
 extern void populate_rootfs(void);
+extern void driver_init(void);
 
 #ifdef CONFIG_TC
 extern void tc_init(void);
@@ -476,6 +477,8 @@ static void __init do_initcalls(void)
  */
 static void __init do_basic_setup(void)
 {
+       driver_init();
+
 #ifdef CONFIG_SYSCTL
        sysctl_init();
 #endif