Commit b99d34fb authored by Linus Torvalds's avatar Linus Torvalds

Merge bk://ldm.bkbits.net/linux-2.5-core

into home.transmeta.com:/home/torvalds/v2.5/linux
parents bc1f1afe dcba0659
...@@ -343,11 +343,40 @@ void device_unregister(struct device * dev) ...@@ -343,11 +343,40 @@ void device_unregister(struct device * dev)
put_device(dev); put_device(dev);
} }
/**
* device_for_each_child - device child iterator.
* @dev: parent struct device.
* @data: data for the callback.
* @fn: function to be called for each device.
*
* Iterate over @dev's child devices, and call @fn for each,
* passing it @data.
*
* We check the return of @fn each time. If it returns anything
* other than 0, we break out and return that value.
*/
int device_for_each_child(struct device * dev, void * data,
int (*fn)(struct device *, void *))
{
struct device * child;
int error = 0;
down_read(&devices_subsys.rwsem);
list_for_each_entry(child,&dev->children,node) {
if((error = fn(child,data)))
break;
}
up_read(&devices_subsys.rwsem);
return error;
}
int __init devices_init(void) int __init devices_init(void)
{ {
return subsystem_register(&devices_subsys); return subsystem_register(&devices_subsys);
} }
EXPORT_SYMBOL(device_for_each_child);
EXPORT_SYMBOL(device_initialize); EXPORT_SYMBOL(device_initialize);
EXPORT_SYMBOL(device_add); EXPORT_SYMBOL(device_add);
EXPORT_SYMBOL(device_register); EXPORT_SYMBOL(device_register);
......
...@@ -49,38 +49,6 @@ static struct file_system_type **find_filesystem(const char *name) ...@@ -49,38 +49,6 @@ static struct file_system_type **find_filesystem(const char *name)
return p; return p;
} }
/* define fs_subsys */
static decl_subsys(fs, NULL, 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
...@@ -111,12 +79,6 @@ int register_filesystem(struct file_system_type * fs) ...@@ -111,12 +79,6 @@ 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. */
register_fs_subsys(fs);
}
return res; return res;
} }
...@@ -134,44 +96,21 @@ int register_filesystem(struct file_system_type * fs) ...@@ -134,44 +96,21 @@ int register_filesystem(struct file_system_type * fs)
int unregister_filesystem(struct file_system_type * fs) int unregister_filesystem(struct file_system_type * fs)
{ {
int res; struct file_system_type ** tmp;
res = unlink_fs(fs);
if (!res)
subsystem_unregister(&fs->subsys);
return res;
}
extern int sysfs_init(void);
/**
* fs_subsys_init - initialize sysfs and fs subsystem.
*
* In order to register filesystems in sysfs, it has to be
* 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) write_lock(&file_systems_lock);
/* make sure it's registered */ tmp = &file_systems;
register_fs_subsys(*p); 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;
} }
static int fs_index(const char __user * __name) static int fs_index(const char __user * __name)
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <asm/uaccess.h> #include <asm/uaccess.h>
extern int __init init_rootfs(void); extern int __init init_rootfs(void);
extern int __init fs_subsys_init(void); extern int __init sysfs_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;
...@@ -1144,7 +1144,7 @@ void __init mnt_init(unsigned long mempages) ...@@ -1144,7 +1144,7 @@ void __init mnt_init(unsigned long mempages)
d++; d++;
i--; i--;
} while (i); } while (i);
fs_subsys_init(); sysfs_init();
init_rootfs(); init_rootfs();
init_mount_tree(); init_mount_tree();
} }
...@@ -194,7 +194,6 @@ struct class_device { ...@@ -194,7 +194,6 @@ struct class_device {
void * class_data; /* class-specific data */ void * class_data; /* class-specific data */
char class_id[BUS_ID_SIZE]; /* unique to this class */ char class_id[BUS_ID_SIZE]; /* unique to this class */
void (*release)(struct class_device * class_dev);
}; };
static inline void * static inline void *
...@@ -303,6 +302,8 @@ extern void device_unregister(struct device * dev); ...@@ -303,6 +302,8 @@ extern void device_unregister(struct device * dev);
extern void device_initialize(struct device * dev); extern void device_initialize(struct device * dev);
extern int device_add(struct device * dev); extern int device_add(struct device * dev);
extern void device_del(struct device * dev); extern void device_del(struct device * dev);
extern int device_for_each_child(struct device *, void *,
int (*fn)(struct device *, void *));
/* /*
* Manual binding of a device to driver. See drivers/base/bus.c * Manual binding of a device to driver. See drivers/base/bus.c
......
...@@ -917,7 +917,6 @@ struct export_operations { ...@@ -917,7 +917,6 @@ 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, struct super_block *(*get_sb) (struct file_system_type *, int,
const char *, void *); const char *, void *);
......
...@@ -17,10 +17,6 @@ ...@@ -17,10 +17,6 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/stat.h> #include <linux/stat.h>
/* This lock can be removed entirely when the sysfs_init() code is cleaned up
* to not try to reference itself before it is initialized. */
static spinlock_t kobj_lock = SPIN_LOCK_UNLOCKED;
/** /**
* populate_dir - populate directory with attributes. * populate_dir - populate directory with attributes.
* @kobj: object we're working on. * @kobj: object we're working on.
...@@ -350,14 +346,12 @@ void kobject_unregister(struct kobject * kobj) ...@@ -350,14 +346,12 @@ void kobject_unregister(struct kobject * kobj)
struct kobject * kobject_get(struct kobject * kobj) struct kobject * kobject_get(struct kobject * kobj)
{ {
struct kobject * ret = kobj; struct kobject * ret = kobj;
unsigned long flags;
spin_lock_irqsave(&kobj_lock, flags); if (kobj) {
if (kobj && atomic_read(&kobj->refcount) > 0) WARN_ON(!atomic_read(&kobj->refcount));
atomic_inc(&kobj->refcount); atomic_inc(&kobj->refcount);
else } else
ret = NULL; ret = NULL;
spin_unlock_irqrestore(&kobj_lock, flags);
return ret; return ret;
} }
...@@ -387,15 +381,8 @@ void kobject_cleanup(struct kobject * kobj) ...@@ -387,15 +381,8 @@ void kobject_cleanup(struct kobject * kobj)
void kobject_put(struct kobject * kobj) void kobject_put(struct kobject * kobj)
{ {
unsigned long flags; if (atomic_dec_and_test(&kobj->refcount))
local_irq_save(flags);
if (atomic_dec_and_lock(&kobj->refcount, &kobj_lock)) {
spin_unlock_irqrestore(&kobj_lock, flags);
kobject_cleanup(kobj); kobject_cleanup(kobj);
} else {
local_irq_restore(flags);
}
} }
......
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