Commit fa0aa7cc authored by Patrick Mochel's avatar Patrick Mochel

driver model: Make initialization explicit.

- 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. 
parent 0a6bca96
......@@ -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
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......@@ -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);
#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();
}
......@@ -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);
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment