Commit 67d93a0a 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 9beb225e 473c7105
...@@ -259,34 +259,22 @@ struct device * get_device(struct device * dev) ...@@ -259,34 +259,22 @@ struct device * get_device(struct device * dev)
*/ */
void put_device(struct device * dev) void put_device(struct device * dev)
{ {
struct device * parent;
if (!atomic_dec_and_lock(&dev->refcount,&device_lock)) if (!atomic_dec_and_lock(&dev->refcount,&device_lock))
return; return;
parent = dev->parent; list_del_init(&dev->node);
dev->parent = NULL; list_del_init(&dev->g_list);
list_del_init(&dev->bus_list);
list_del_init(&dev->driver_list);
spin_unlock(&device_lock); spin_unlock(&device_lock);
BUG_ON(dev->present); BUG_ON(dev->present);
if (dev->release) device_del(dev);
dev->release(dev);
if (parent)
put_device(parent);
} }
void device_del(struct device * dev) void device_del(struct device * dev)
{ {
spin_lock(&device_lock); struct device * parent = dev->parent;
dev->present = 0;
list_del_init(&dev->node);
list_del_init(&dev->g_list);
list_del_init(&dev->bus_list);
list_del_init(&dev->driver_list);
spin_unlock(&device_lock);
pr_debug("DEV: Unregistering device. ID = '%s', name = '%s'\n",
dev->bus_id,dev->name);
/* Notify the platform of the removal, in case they /* Notify the platform of the removal, in case they
* need to do anything... * need to do anything...
...@@ -302,6 +290,12 @@ void device_del(struct device * dev) ...@@ -302,6 +290,12 @@ void device_del(struct device * dev)
/* remove the driverfs directory */ /* remove the driverfs directory */
device_remove_dir(dev); device_remove_dir(dev);
if (dev->release)
dev->release(dev);
if (parent)
put_device(parent);
} }
/** /**
...@@ -315,22 +309,15 @@ void device_del(struct device * dev) ...@@ -315,22 +309,15 @@ void device_del(struct device * dev)
*/ */
void device_unregister(struct device * dev) void device_unregister(struct device * dev)
{ {
device_del(dev); spin_lock(&device_lock);
put_device(dev); dev->present = 0;
} spin_unlock(&device_lock);
static int __init device_init(void)
{
int error;
error = init_driverfs_fs(); pr_debug("DEV: Unregistering device. ID = '%s', name = '%s'\n",
if (error) dev->bus_id,dev->name);
panic("DEV: could not initialize driverfs"); put_device(dev);
return 0;
} }
core_initcall(device_init);
EXPORT_SYMBOL(device_register); EXPORT_SYMBOL(device_register);
EXPORT_SYMBOL(device_unregister); EXPORT_SYMBOL(device_unregister);
EXPORT_SYMBOL(get_device); EXPORT_SYMBOL(get_device);
......
...@@ -509,11 +509,13 @@ static void put_mount(void) ...@@ -509,11 +509,13 @@ static void put_mount(void)
DBG("driverfs: mount_count = %d\n",mount_count); DBG("driverfs: mount_count = %d\n",mount_count);
} }
int __init init_driverfs_fs(void) static int __init driverfs_init(void)
{ {
return register_filesystem(&driverfs_fs_type); return register_filesystem(&driverfs_fs_type);
} }
core_initcall(driverfs_init);
static struct dentry * get_dentry(struct dentry * parent, const char * name) static struct dentry * get_dentry(struct dentry * parent, const char * name)
{ {
struct qstr qstr; struct qstr qstr;
......
...@@ -65,6 +65,4 @@ driverfs_create_symlink(struct driver_dir_entry * parent, ...@@ -65,6 +65,4 @@ driverfs_create_symlink(struct driver_dir_entry * parent,
extern void extern void
driverfs_remove_file(struct driver_dir_entry *, const char * name); driverfs_remove_file(struct driver_dir_entry *, const char * name);
extern int init_driverfs_fs(void);
#endif /* _DDFS_H_ */ #endif /* _DDFS_H_ */
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