Commit 3221c18e authored by Patrick Mochel's avatar Patrick Mochel

Merge osdl.org:/home/mochel/src/kernel/devel/linux-2.5-virgin

into osdl.org:/home/mochel/src/kernel/devel/linux-2.5-core
parents 3188a3b6 8811d235
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
obj-y := core.o sys.o interface.o power.o bus.o \ obj-y := core.o sys.o interface.o power.o bus.o \
driver.o class.o intf.o platform.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-$(CONFIG_NUMA) += node.o memblk.o
obj-y += fs/ obj-y += fs/
obj-$(CONFIG_HOTPLUG) += hotplug.o obj-$(CONFIG_HOTPLUG) += hotplug.o
...@@ -544,12 +544,11 @@ void bus_unregister(struct bus_type * bus) ...@@ -544,12 +544,11 @@ void bus_unregister(struct bus_type * bus)
subsystem_unregister(&bus->subsys); subsystem_unregister(&bus->subsys);
} }
static int __init bus_subsys_init(void) int __init buses_init(void)
{ {
return subsystem_register(&bus_subsys); return subsystem_register(&bus_subsys);
} }
core_initcall(bus_subsys_init);
EXPORT_SYMBOL(bus_for_each_dev); EXPORT_SYMBOL(bus_for_each_dev);
EXPORT_SYMBOL(bus_for_each_drv); EXPORT_SYMBOL(bus_for_each_drv);
......
...@@ -266,13 +266,11 @@ void devclass_unregister(struct device_class * cls) ...@@ -266,13 +266,11 @@ void devclass_unregister(struct device_class * cls)
subsystem_unregister(&cls->subsys); subsystem_unregister(&cls->subsys);
} }
static int __init class_subsys_init(void) int __init classes_init(void)
{ {
return subsystem_register(&class_subsys); return subsystem_register(&class_subsys);
} }
core_initcall(class_subsys_init);
EXPORT_SYMBOL(devclass_create_file); EXPORT_SYMBOL(devclass_create_file);
EXPORT_SYMBOL(devclass_remove_file); EXPORT_SYMBOL(devclass_remove_file);
EXPORT_SYMBOL(devclass_register); EXPORT_SYMBOL(devclass_register);
......
...@@ -309,13 +309,11 @@ void device_unregister(struct device * dev) ...@@ -309,13 +309,11 @@ void device_unregister(struct device * dev)
put_device(dev); put_device(dev);
} }
static int __init device_subsys_init(void) int __init devices_init(void)
{ {
return subsystem_register(&devices_subsys); return subsystem_register(&devices_subsys);
} }
core_initcall(device_subsys_init);
EXPORT_SYMBOL(device_initialize); EXPORT_SYMBOL(device_initialize);
EXPORT_SYMBOL(device_add); EXPORT_SYMBOL(device_add);
EXPORT_SYMBOL(device_register); EXPORT_SYMBOL(device_register);
......
...@@ -46,9 +46,8 @@ int __init register_cpu(struct cpu *cpu, int num, struct node *root) ...@@ -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); devclass_register(&cpu_devclass);
return driver_register(&cpu_driver); return driver_register(&cpu_driver);
} }
postcore_initcall(register_cpu_type);
...@@ -19,12 +19,10 @@ void firmware_unregister(struct subsystem * s) ...@@ -19,12 +19,10 @@ void firmware_unregister(struct subsystem * s)
subsystem_unregister(s); subsystem_unregister(s);
} }
static int __init firmware_init(void) int __init firmware_init(void)
{ {
return subsystem_register(&firmware_subsys); return subsystem_register(&firmware_subsys);
} }
core_initcall(firmware_init);
EXPORT_SYMBOL(firmware_register); EXPORT_SYMBOL(firmware_register);
EXPORT_SYMBOL(firmware_unregister); 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 platform_bus_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.
*/
platform_bus_init();
sys_bus_init();
cpu_dev_init();
}
...@@ -41,9 +41,29 @@ void platform_device_unregister(struct platform_device * pdev) ...@@ -41,9 +41,29 @@ void platform_device_unregister(struct platform_device * pdev)
if (pdev) if (pdev)
device_unregister(&pdev->dev); device_unregister(&pdev->dev);
} }
/**
* platform_match - bind platform device to platform driver.
* @dev: device.
* @drv: driver.
*
* Platform device IDs are assumed to be encoded like this:
* "<name><instance>", where <name> is a short description of the
* type of device, like "pci" or "floppy", and <instance> is the
* enumerated instance of the device, like '0' or '42'.
* Driver IDs are simply "<name>".
* So, extract the <name> from the device, and compare it against
* the name of the driver. Return whether they match or not.
*/
static int platform_match(struct device * dev, struct device_driver * drv) static int platform_match(struct device * dev, struct device_driver * drv)
{ {
char name[BUS_ID_SIZE];
if (sscanf(dev->bus_id,"%s",name))
return (strcmp(name,drv->name) == 0);
return 0; return 0;
} }
...@@ -52,13 +72,11 @@ struct bus_type platform_bus_type = { ...@@ -52,13 +72,11 @@ struct bus_type platform_bus_type = {
.match = platform_match, .match = platform_match,
}; };
static int __init platform_bus_init(void) int __init platform_bus_init(void)
{ {
device_register(&legacy_bus); device_register(&legacy_bus);
return bus_register(&platform_bus_type); return bus_register(&platform_bus_type);
} }
postcore_initcall(platform_bus_init);
EXPORT_SYMBOL(platform_device_register); EXPORT_SYMBOL(platform_device_register);
EXPORT_SYMBOL(platform_device_unregister); EXPORT_SYMBOL(platform_device_unregister);
...@@ -138,13 +138,12 @@ struct bus_type system_bus_type = { ...@@ -138,13 +138,12 @@ struct bus_type system_bus_type = {
.name = "system", .name = "system",
}; };
static int sys_bus_init(void) int __init sys_bus_init(void)
{ {
bus_register(&system_bus_type); bus_register(&system_bus_type);
return device_register(&system_bus); return device_register(&system_bus);
} }
postcore_initcall(sys_bus_init);
EXPORT_SYMBOL(system_bus_type); EXPORT_SYMBOL(system_bus_type);
EXPORT_SYMBOL(sys_device_register); EXPORT_SYMBOL(sys_device_register);
EXPORT_SYMBOL(sys_device_unregister); EXPORT_SYMBOL(sys_device_unregister);
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/kmod.h> #include <linux/kmod.h>
#include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -58,6 +59,38 @@ static struct file_system_type **find_filesystem(const char *name) ...@@ -58,6 +59,38 @@ static struct file_system_type **find_filesystem(const char *name)
return p; return p;
} }
/* define fs_subsys */
static decl_subsys(fs, NULL);
static int register_fs_subsys(struct file_system_type * fs)
{
struct subsystem *sub = &fs->subsys;
snprintf(sub->kset.kobj.name, KOBJ_NAME_LEN, "%s", fs->name);
subsys_set_kset(fs, fs_subsys);
return subsystem_register(sub);
}
static int unlink_fs(struct file_system_type * fs)
{
struct file_system_type ** tmp;
write_lock(&file_systems_lock);
tmp = &file_systems;
while (*tmp) {
if (fs == *tmp) {
*tmp = fs->next;
fs->next = NULL;
write_unlock(&file_systems_lock);
return 0;
}
tmp = &(*tmp)->next;
}
write_unlock(&file_systems_lock);
return -EINVAL;
}
/** /**
* register_filesystem - register a new filesystem * register_filesystem - register a new filesystem
* @fs: the file system structure * @fs: the file system structure
...@@ -88,6 +121,14 @@ int register_filesystem(struct file_system_type * fs) ...@@ -88,6 +121,14 @@ int register_filesystem(struct file_system_type * fs)
else else
*p = fs; *p = fs;
write_unlock(&file_systems_lock); write_unlock(&file_systems_lock);
if (!res) {
/* we implicitly possess reference to @fs during registration,
* so it cannot be unregister from under us. */
if (register_fs_subsys(fs))
printk(KERN_WARNING "Failed to register '%s' in sysfs\n",
fs->name);
}
return res; return res;
} }
...@@ -105,21 +146,44 @@ int register_filesystem(struct file_system_type * fs) ...@@ -105,21 +146,44 @@ int register_filesystem(struct file_system_type * fs)
int unregister_filesystem(struct file_system_type * fs) int unregister_filesystem(struct file_system_type * fs)
{ {
struct file_system_type ** tmp; int res;
write_lock(&file_systems_lock); res = unlink_fs(fs);
tmp = &file_systems; if (!res)
while (*tmp) { subsystem_unregister(&fs->subsys);
if (fs == *tmp) { return res;
*tmp = fs->next; }
fs->next = NULL;
write_unlock(&file_systems_lock); extern int sysfs_init(void);
return 0;
} /**
tmp = &(*tmp)->next; * fs_subsys_init - initialize sysfs and fs subsystem.
} *
write_unlock(&file_systems_lock); * In order to register filesystems in sysfs, it has to be
return -EINVAL; * initialized. Also, we need the base fs filesystem, so the
* registered filesystems have a home.
*
* During sysfs_init(), the registration of sysfs into itself
* will fail, since it's not mounted yet. To make sure that
* sysfs does show up, we re-register sysfs's embedded subsystem,
* which will get added, since sysfs is now mounted.
*/
void __init fs_subsys_init(void)
{
struct file_system_type ** p;
/* make sure sysfs is up and running */
sysfs_init();
/* register fs_subsys */
subsystem_register(&fs_subsys);
p = find_filesystem("sysfs");
if (p)
/* make sure it's registered */
register_fs_subsys(*p);
} }
static int fs_index(const char * __name) static int fs_index(const char * __name)
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
extern struct vfsmount *do_kern_mount(const char *type, int flags, char *name, void *data); extern struct vfsmount *do_kern_mount(const char *type, int flags, char *name, void *data);
extern int do_remount_sb(struct super_block *sb, int flags, void * data); extern int do_remount_sb(struct super_block *sb, int flags, void * data);
extern int __init init_rootfs(void); extern int __init init_rootfs(void);
extern int __init fs_subsys_init(void);
static struct list_head *mount_hashtable; static struct list_head *mount_hashtable;
static int hash_mask, hash_bits; static int hash_mask, hash_bits;
...@@ -1132,6 +1133,7 @@ void __init mnt_init(unsigned long mempages) ...@@ -1132,6 +1133,7 @@ void __init mnt_init(unsigned long mempages)
d++; d++;
i--; i--;
} while (i); } while (i);
fs_subsys_init();
init_rootfs(); init_rootfs();
init_mount_tree(); init_mount_tree();
} }
...@@ -226,6 +226,7 @@ int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr) ...@@ -226,6 +226,7 @@ int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr)
int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr) int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr)
{ {
sysfs_hash_and_remove(kobj->dentry,attr->attr.name); sysfs_hash_and_remove(kobj->dentry,attr->attr.name);
return 0;
} }
EXPORT_SYMBOL(sysfs_create_bin_file); EXPORT_SYMBOL(sysfs_create_bin_file);
......
...@@ -66,7 +66,7 @@ static struct file_system_type sysfs_fs_type = { ...@@ -66,7 +66,7 @@ static struct file_system_type sysfs_fs_type = {
.kill_sb = kill_litter_super, .kill_sb = kill_litter_super,
}; };
static int __init sysfs_init(void) int __init sysfs_init(void)
{ {
int err; int err;
...@@ -81,5 +81,3 @@ static int __init sysfs_init(void) ...@@ -81,5 +81,3 @@ static int __init sysfs_init(void)
} }
return err; return err;
} }
core_initcall(sysfs_init);
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/cache.h> #include <linux/cache.h>
#include <linux/radix-tree.h> #include <linux/radix-tree.h>
#include <linux/kobject.h>
#include <asm/atomic.h> #include <asm/atomic.h>
struct iovec; struct iovec;
...@@ -610,6 +611,7 @@ struct super_block { ...@@ -610,6 +611,7 @@ struct super_block {
char s_id[32]; /* Informational name */ char s_id[32]; /* Informational name */
struct kobject kobj; /* anchor for sysfs */
void *s_fs_info; /* Filesystem private info */ void *s_fs_info; /* Filesystem private info */
/* /*
...@@ -913,6 +915,7 @@ struct export_operations { ...@@ -913,6 +915,7 @@ struct export_operations {
struct file_system_type { struct file_system_type {
const char *name; const char *name;
struct subsystem subsys;
int fs_flags; int fs_flags;
struct super_block *(*get_sb) (struct file_system_type *, int, char *, void *); struct super_block *(*get_sb) (struct file_system_type *, int, char *, void *);
void (*kill_sb) (struct super_block *); void (*kill_sb) (struct super_block *);
......
...@@ -71,6 +71,7 @@ extern void pte_chain_init(void); ...@@ -71,6 +71,7 @@ extern void pte_chain_init(void);
extern void radix_tree_init(void); extern void radix_tree_init(void);
extern void free_initmem(void); extern void free_initmem(void);
extern void populate_rootfs(void); extern void populate_rootfs(void);
extern void driver_init(void);
#ifdef CONFIG_TC #ifdef CONFIG_TC
extern void tc_init(void); extern void tc_init(void);
...@@ -476,6 +477,8 @@ static void __init do_initcalls(void) ...@@ -476,6 +477,8 @@ static void __init do_initcalls(void)
*/ */
static void __init do_basic_setup(void) static void __init do_basic_setup(void)
{ {
driver_init();
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
sysctl_init(); sysctl_init();
#endif #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