From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org
Cc: gregkh@suse.de
Subject: [PATCH] sysdev: remove the rwsem usage from this subsystem.
Date: Wed, 9 Mar 2005 16:34:46 -0800 [thread overview]
Message-ID: <11104148863516@kroah.com> (raw)
In-Reply-To: <1110414886525@kroah.com>
ChangeSet 1.2054, 2005/03/09 15:39:09-08:00, gregkh@suse.de
[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: Greg Kroah-Hartman <gregkh@suse.de>
drivers/base/sys.c | 21 +++++++++++----------
1 files changed, 11 insertions(+), 10 deletions(-)
diff -Nru a/drivers/base/sys.c b/drivers/base/sys.c
--- a/drivers/base/sys.c 2005-03-09 16:28:10 -08:00
+++ b/drivers/base/sys.c 2005-03-09 16:28:10 -08:00
@@ -103,6 +103,7 @@
static LIST_HEAD(sysdev_drivers);
+static DECLARE_MUTEX(sysdev_drivers_lock);
/**
* sysdev_driver_register - Register auxillary driver
@@ -119,7 +120,7 @@
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 @@
}
} else
list_add_tail(&drv->entry, &sysdev_drivers);
- up_write(&system_subsys.rwsem);
+ up(&sysdev_drivers_lock);
return 0;
}
@@ -144,7 +145,7 @@
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 @@
}
kset_put(&cls->kset);
}
- up_write(&system_subsys.rwsem);
+ up(&sysdev_drivers_lock);
}
EXPORT_SYMBOL_GPL(sysdev_driver_register);
@@ -193,7 +194,7 @@
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 @@
if (drv->add)
drv->add(sysdev);
}
- up_write(&system_subsys.rwsem);
+ up(&sysdev_drivers_lock);
}
return error;
}
@@ -218,7 +219,7 @@
{
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 @@
if (drv->remove)
drv->remove(sysdev);
}
- up_write(&system_subsys.rwsem);
+ up(&sysdev_drivers_lock);
kobject_unregister(&sysdev->kobj);
}
@@ -255,7 +256,7 @@
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 @@
cls->shutdown(sysdev);
}
}
- up_write(&system_subsys.rwsem);
+ up(&sysdev_drivers_lock);
}
next prev parent reply other threads:[~2005-03-10 2:40 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-10 0:34 [BK PATCH] Driver core and kobject updates for 2.6.11 Greg KH
2005-03-10 0:34 ` [PATCH] Kobject: remove some unneeded exports Greg KH
2005-03-10 0:34 ` [PATCH] Add 2.4.x cpufreq /proc and sysctl interface removal feature-removal-schedule Greg KH
2005-03-10 0:34 ` [PATCH] cpufreq 2.4 interface removal schedule Greg KH
2005-03-10 0:34 ` [PATCH] driver core: Separate platform device name from platform device number Greg KH
2005-03-10 0:34 ` [PATCH] class core: export MAJOR/MINOR to the hotplug env Greg KH
2005-03-10 0:34 ` [PATCH] block " Greg KH
2005-03-10 0:34 ` [PATCH] class_simple: pass dev_t to the class core Greg KH
2005-03-10 0:34 ` [PATCH] usb: class driver " Greg KH
2005-03-10 0:34 ` [PATCH] i2c: " Greg KH
2005-03-10 0:34 ` [PATCH] videodev: " Greg KH
2005-03-10 0:34 ` [PATCH] driver core: clean driver unload Greg KH
2005-03-10 0:34 ` [PATCH] Driver core: add "bus" symlink to class/block devices Greg KH
2005-03-10 0:34 ` [PATCH] floppy.c: pass physical device to device registration Greg KH
2005-03-10 0:34 ` [PATCH] kset: make ksets have a spinlock, and use that to lock their lists Greg KH
2005-03-10 0:34 ` [PATCH] sysdev: make system_subsys static as no one else needs access to it Greg KH
2005-03-10 0:34 ` [PATCH] kref: make kref_put return if this was the last put call Greg KH
2005-03-10 0:34 ` [PATCH] USB: move usb core to use class_simple instead of it's own class functions Greg KH
2005-03-10 0:34 ` [PATCH] kmap: remove usage of rwsem from kobj_map Greg KH
2005-03-10 0:34 ` [PATCH] sysdev: fix the name of the list of drivers to be a sane name Greg KH
2005-03-10 0:34 ` Greg KH [this message]
2005-03-10 0:34 ` [PATCH] class: add a semaphore to struct class, and use that instead of the subsystem rwsem Greg KH
2005-03-25 18:01 ` [PATCH] driver core: Separate platform device name from platform device number Paul Mundt
2005-03-25 18:10 ` Greg KH
2005-03-25 18:35 ` Paul Mundt
2005-03-25 19:38 ` Kyle Moffett
2005-03-25 19:58 ` Paul Mundt
2005-03-25 20:17 ` Kyle Moffett
2005-03-25 20:25 ` Russell King
2005-03-25 20:56 ` Paul Mundt
2005-03-25 21:03 ` Russell King
2005-03-25 22:15 ` Paul Mundt
2005-03-10 2:23 ` [PATCH] Add 2.4.x cpufreq /proc and sysctl interface removal feature-removal-schedule Dave Jones
2005-03-10 4:56 ` Dominik Brodowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11104148863516@kroah.com \
--to=greg@kroah.com \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox