lkml.org 
[lkml]   [2008]   [Jan]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 7/7] driver-core : convert semaphore to mutex in struct class
On Tue, Jan 15, 2008 at 05:15:27PM +0800, Dave Young wrote:
> Convert the class semaphore to mutex.
>
> Signed-off-by: Dave Young <hidave.darkstar@gmail.com>
>
> ---
> drivers/base/class.c | 38 +++++++++++++++++++-------------------
> drivers/base/core.c | 18 ++++++++----------
> include/linux/device.h | 3 ++-
> 3 files changed, 29 insertions(+), 30 deletions(-)
>
> diff -upr linux/drivers/base/class.c linux.new/drivers/base/class.c
> --- linux/drivers/base/class.c 2008-01-15 14:04:26.000000000 +0800
> +++ linux.new/drivers/base/class.c 2008-01-15 14:04:26.000000000 +0800
> @@ -144,7 +144,7 @@ int class_register(struct class * cls)
> INIT_LIST_HEAD(&cls->devices);
> INIT_LIST_HEAD(&cls->interfaces);
> kset_init(&cls->class_dirs);
> - init_MUTEX(&cls->sem);
> + mutex_init(&cls->mutex);
> error = kobject_set_name(&cls->subsys.kobj, "%s", cls->name);
> if (error)
> return error;
> @@ -617,13 +617,13 @@ int class_device_add(struct class_device
> kobject_uevent(&class_dev->kobj, KOBJ_ADD);
>
> /* notify any interfaces this device is now here */
> - down(&parent_class->sem);
> + mutex_lock_nested(&parent_class->mutex, SINGLE_DEPTH_NESTING);
> list_add_tail(&class_dev->node, &parent_class->children);
> list_for_each_entry(class_intf, &parent_class->interfaces, node) {
> if (class_intf->add)
> class_intf->add(class_dev, class_intf);
> }
> - up(&parent_class->sem);
> + mutex_unlock(&parent_class->mutex);
>
> goto out1;
>
> @@ -725,12 +725,12 @@ void class_device_del(struct class_devic
> struct class_interface *class_intf;
>
> if (parent_class) {
> - down(&parent_class->sem);
> + mutex_lock(&parent_class->mutex);

I hope I'm wrong with this (I don't know this code at all...), and
of course I should've noticed this earlier after all, but I wonder
about this _NESTING corretness here. So, if these variables names
are right, and say about real nesting dependency, then it seems
mutex_lock_nested() should be used consistently even if (currently?)
not forced by lockdep warnings; otherwise this could possibly cover
some other warnings. Alas, if accidentally I'm right, it seems a
bit of new testing would be necessary...

Regards,
Jarek P.


\
 
 \ /
  Last update: 2008-01-15 14:53    [W:0.128 / U:0.528 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site