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); ...@@ -103,6 +103,7 @@ EXPORT_SYMBOL_GPL(sysdev_class_unregister);
static LIST_HEAD(sysdev_drivers); static LIST_HEAD(sysdev_drivers);
static DECLARE_MUTEX(sysdev_drivers_lock);
/** /**
* sysdev_driver_register - Register auxillary driver * sysdev_driver_register - Register auxillary driver
...@@ -119,7 +120,7 @@ static LIST_HEAD(sysdev_drivers); ...@@ -119,7 +120,7 @@ static LIST_HEAD(sysdev_drivers);
int sysdev_driver_register(struct sysdev_class * cls, int sysdev_driver_register(struct sysdev_class * cls,
struct sysdev_driver * drv) struct sysdev_driver * drv)
{ {
down_write(&system_subsys.rwsem); down(&sysdev_drivers_lock);
if (cls && kset_get(&cls->kset)) { if (cls && kset_get(&cls->kset)) {
list_add_tail(&drv->entry, &cls->drivers); list_add_tail(&drv->entry, &cls->drivers);
...@@ -131,7 +132,7 @@ int sysdev_driver_register(struct sysdev_class * cls, ...@@ -131,7 +132,7 @@ int sysdev_driver_register(struct sysdev_class * cls,
} }
} else } else
list_add_tail(&drv->entry, &sysdev_drivers); list_add_tail(&drv->entry, &sysdev_drivers);
up_write(&system_subsys.rwsem); up(&sysdev_drivers_lock);
return 0; return 0;
} }
...@@ -144,7 +145,7 @@ int sysdev_driver_register(struct sysdev_class * cls, ...@@ -144,7 +145,7 @@ int sysdev_driver_register(struct sysdev_class * cls,
void sysdev_driver_unregister(struct sysdev_class * cls, void sysdev_driver_unregister(struct sysdev_class * cls,
struct sysdev_driver * drv) struct sysdev_driver * drv)
{ {
down_write(&system_subsys.rwsem); down(&sysdev_drivers_lock);
list_del_init(&drv->entry); list_del_init(&drv->entry);
if (cls) { if (cls) {
if (drv->remove) { if (drv->remove) {
...@@ -154,7 +155,7 @@ void sysdev_driver_unregister(struct sysdev_class * cls, ...@@ -154,7 +155,7 @@ void sysdev_driver_unregister(struct sysdev_class * cls,
} }
kset_put(&cls->kset); kset_put(&cls->kset);
} }
up_write(&system_subsys.rwsem); up(&sysdev_drivers_lock);
} }
EXPORT_SYMBOL_GPL(sysdev_driver_register); EXPORT_SYMBOL_GPL(sysdev_driver_register);
...@@ -193,7 +194,7 @@ int sysdev_register(struct sys_device * sysdev) ...@@ -193,7 +194,7 @@ int sysdev_register(struct sys_device * sysdev)
if (!error) { if (!error) {
struct sysdev_driver * drv; struct sysdev_driver * drv;
down_write(&system_subsys.rwsem); down(&sysdev_drivers_lock);
/* Generic notification is implicit, because it's that /* Generic notification is implicit, because it's that
* code that should have called us. * code that should have called us.
*/ */
...@@ -209,7 +210,7 @@ int sysdev_register(struct sys_device * sysdev) ...@@ -209,7 +210,7 @@ int sysdev_register(struct sys_device * sysdev)
if (drv->add) if (drv->add)
drv->add(sysdev); drv->add(sysdev);
} }
up_write(&system_subsys.rwsem); up(&sysdev_drivers_lock);
} }
return error; return error;
} }
...@@ -218,7 +219,7 @@ void sysdev_unregister(struct sys_device * sysdev) ...@@ -218,7 +219,7 @@ void sysdev_unregister(struct sys_device * sysdev)
{ {
struct sysdev_driver * drv; struct sysdev_driver * drv;
down_write(&system_subsys.rwsem); down(&sysdev_drivers_lock);
list_for_each_entry(drv, &sysdev_drivers, entry) { list_for_each_entry(drv, &sysdev_drivers, entry) {
if (drv->remove) if (drv->remove)
drv->remove(sysdev); drv->remove(sysdev);
...@@ -228,7 +229,7 @@ void sysdev_unregister(struct sys_device * sysdev) ...@@ -228,7 +229,7 @@ void sysdev_unregister(struct sys_device * sysdev)
if (drv->remove) if (drv->remove)
drv->remove(sysdev); drv->remove(sysdev);
} }
up_write(&system_subsys.rwsem); up(&sysdev_drivers_lock);
kobject_unregister(&sysdev->kobj); kobject_unregister(&sysdev->kobj);
} }
...@@ -255,7 +256,7 @@ void sysdev_shutdown(void) ...@@ -255,7 +256,7 @@ void sysdev_shutdown(void)
pr_debug("Shutting Down System Devices\n"); 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, list_for_each_entry_reverse(cls, &system_subsys.kset.list,
kset.kobj.entry) { kset.kobj.entry) {
struct sys_device * sysdev; struct sys_device * sysdev;
...@@ -284,7 +285,7 @@ void sysdev_shutdown(void) ...@@ -284,7 +285,7 @@ void sysdev_shutdown(void)
cls->shutdown(sysdev); 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