Commit d32accb0 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

[PATCH] sysdev: remove the rwsem usage from this subsystem.

If further finer grained locking is needed, we can add a lock to the sysdev_class to
lock the class drivers list.  But if you do that, remember the global list also is still
there and needs to be protected.  That's why I went with a simple lock for everything.
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 11cdd9aa
......@@ -103,6 +103,7 @@ EXPORT_SYMBOL_GPL(sysdev_class_unregister);
static LIST_HEAD(sysdev_drivers);
static DECLARE_MUTEX(sysdev_drivers_lock);
/**
* sysdev_driver_register - Register auxillary driver
......@@ -119,7 +120,7 @@ static LIST_HEAD(sysdev_drivers);
int sysdev_driver_register(struct sysdev_class * cls,
struct sysdev_driver * drv)
{
down_write(&system_subsys.rwsem);
down(&sysdev_drivers_lock);
if (cls && kset_get(&cls->kset)) {
list_add_tail(&drv->entry, &cls->drivers);
......@@ -131,7 +132,7 @@ int sysdev_driver_register(struct sysdev_class * cls,
}
} else
list_add_tail(&drv->entry, &sysdev_drivers);
up_write(&system_subsys.rwsem);
up(&sysdev_drivers_lock);
return 0;
}
......@@ -144,7 +145,7 @@ int sysdev_driver_register(struct sysdev_class * cls,
void sysdev_driver_unregister(struct sysdev_class * cls,
struct sysdev_driver * drv)
{
down_write(&system_subsys.rwsem);
down(&sysdev_drivers_lock);
list_del_init(&drv->entry);
if (cls) {
if (drv->remove) {
......@@ -154,7 +155,7 @@ void sysdev_driver_unregister(struct sysdev_class * cls,
}
kset_put(&cls->kset);
}
up_write(&system_subsys.rwsem);
up(&sysdev_drivers_lock);
}
EXPORT_SYMBOL_GPL(sysdev_driver_register);
......@@ -193,7 +194,7 @@ int sysdev_register(struct sys_device * sysdev)
if (!error) {
struct sysdev_driver * drv;
down_write(&system_subsys.rwsem);
down(&sysdev_drivers_lock);
/* Generic notification is implicit, because it's that
* code that should have called us.
*/
......@@ -209,7 +210,7 @@ int sysdev_register(struct sys_device * sysdev)
if (drv->add)
drv->add(sysdev);
}
up_write(&system_subsys.rwsem);
up(&sysdev_drivers_lock);
}
return error;
}
......@@ -218,7 +219,7 @@ void sysdev_unregister(struct sys_device * sysdev)
{
struct sysdev_driver * drv;
down_write(&system_subsys.rwsem);
down(&sysdev_drivers_lock);
list_for_each_entry(drv, &sysdev_drivers, entry) {
if (drv->remove)
drv->remove(sysdev);
......@@ -228,7 +229,7 @@ void sysdev_unregister(struct sys_device * sysdev)
if (drv->remove)
drv->remove(sysdev);
}
up_write(&system_subsys.rwsem);
up(&sysdev_drivers_lock);
kobject_unregister(&sysdev->kobj);
}
......@@ -255,7 +256,7 @@ void sysdev_shutdown(void)
pr_debug("Shutting Down System Devices\n");
down_write(&system_subsys.rwsem);
down(&sysdev_drivers_lock);
list_for_each_entry_reverse(cls, &system_subsys.kset.list,
kset.kobj.entry) {
struct sys_device * sysdev;
......@@ -284,7 +285,7 @@ void sysdev_shutdown(void)
cls->shutdown(sysdev);
}
}
up_write(&system_subsys.rwsem);
up(&sysdev_drivers_lock);
}
......
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