public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jarek Poplawski <jarkao2@gmail.com>
To: Dave Young <hidave.darkstar@gmail.com>
Cc: Greg KH <gregkh@suse.de>,
	stefanr@s5r6.in-berlin.de, david-b@pacbell.net,
	stern@rowland.harvard.edu, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 7/7] driver-core : convert semaphore to mutex in struct class
Date: Tue, 15 Jan 2008 14:56:04 +0100	[thread overview]
Message-ID: <20080115135604.GD1696@ff.dom.local> (raw)
In-Reply-To: <20080115091527.GB3186@darkstar.te-china.tietoenator.com>

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.

  reply	other threads:[~2008-01-15 13:49 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-12 10:05 [PATCH 7/7] driver-core : convert semaphore to mutex in struct class Dave Young
2008-01-15  9:15 ` Dave Young
2008-01-15 13:56   ` Jarek Poplawski [this message]
2008-01-16  1:03     ` Dave Young
2008-01-16  8:34       ` Jarek Poplawski
2008-01-17  1:17         ` Dave Young
2008-01-17  8:38           ` Jarek Poplawski
2008-01-17  8:56             ` Dave Young
2008-01-16 15:27       ` Alan Stern
2008-01-17  0:01         ` Jarek Poplawski
2008-01-17  1:18         ` Dave Young
2008-01-17 15:16           ` Alan Stern
2008-01-17 19:47             ` Jarek Poplawski
2008-01-17 19:57               ` Alan Stern
2008-01-17 20:31                 ` Jarek Poplawski
2008-01-17 22:02                   ` Jarek Poplawski
2008-01-17 23:26                   ` Jarek Poplawski
2008-01-18  1:42                     ` Dave Young
2008-01-18  1:55                       ` Kay Sievers
2008-01-18  2:28                         ` Dave Young
2008-01-18  3:18                           ` Kay Sievers
2008-01-18  6:25                             ` Greg KH
     [not found]                             ` <a8e1da0801172131h57097622h6d111133b6a0773d@mail.gmail.com>
2008-01-18  7:38                               ` Jarek Poplawski
2008-01-18  7:48                                 ` Dave Young
2008-01-18  8:23                                   ` Jarek Poplawski
2008-01-18  9:07                                     ` Dave Young
2008-01-19  9:39                                       ` Jarek Poplawski
2008-01-21  1:19                                         ` Dave Young
2008-01-21  1:30                                         ` Dave Young
2008-01-21  1:43                                           ` Dave Young
2008-01-21  8:36                                             ` Jarek Poplawski
2008-01-21  8:44                                               ` Dave Young
2008-01-21  9:03                                                 ` Jarek Poplawski
2008-01-21 21:16                                                 ` Jarek Poplawski
2008-01-22  0:55                                                   ` Dave Young
2008-01-22  5:15                                                     ` Greg KH
2008-01-22  6:13                                                       ` Dave Young
2008-01-22  7:45                                                     ` Jarek Poplawski
2008-01-18 10:45                                 ` Kay Sievers
2008-01-18 11:40                                   ` Jarek Poplawski
2008-01-18  8:00                       ` Jarek Poplawski
2008-01-18  8:39                         ` Jarek Poplawski
2008-01-17 21:11                 ` Greg KH
2008-01-17 21:55                   ` Jarek Poplawski
2008-01-18  1:45             ` Dave Young

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=20080115135604.GD1696@ff.dom.local \
    --to=jarkao2@gmail.com \
    --cc=david-b@pacbell.net \
    --cc=gregkh@suse.de \
    --cc=hidave.darkstar@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stefanr@s5r6.in-berlin.de \
    --cc=stern@rowland.harvard.edu \
    /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