From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org
Cc: linux-usb-devel@lists.sourceforge.net,
Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 2/2] [PATCH] Driver core: fix locking issues with the devices that are attached to classes
Date: Thu, 22 Jun 2006 22:58:35 -0700 [thread overview]
Message-ID: <11510423183635-git-send-email-greg@kroah.com> (raw)
In-Reply-To: <11510423151128-git-send-email-greg@kroah.com>
From: Greg Kroah-Hartman <gregkh@suse.de>
Doh, that was foolish...
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/base/core.c | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index d0f84ff..27c2176 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -356,6 +356,13 @@ int device_add(struct device *dev)
if (parent)
klist_add_tail(&dev->knode_parent, &parent->klist_children);
+ if (dev->class) {
+ /* tie the class to the device */
+ down(&dev->class->sem);
+ list_add_tail(&dev->node, &dev->class->devices);
+ up(&dev->class->sem);
+ }
+
/* notify platform of device entry */
if (platform_notify)
platform_notify(dev);
@@ -455,6 +462,9 @@ void device_del(struct device * dev)
sysfs_remove_link(&dev->kobj, "device");
sysfs_remove_link(&dev->parent->kobj, class_name);
kfree(class_name);
+ down(&dev->class->sem);
+ list_del_init(&dev->node);
+ up(&dev->class->sem);
}
device_remove_file(dev, &dev->uevent_attr);
@@ -601,11 +611,6 @@ struct device *device_create(struct clas
if (retval)
goto error;
- /* tie the class to the device */
- down(&class->sem);
- list_add_tail(&dev->node, &class->devices);
- up(&class->sem);
-
return dev;
error:
@@ -636,9 +641,7 @@ void device_destroy(struct class *class,
}
up(&class->sem);
- if (dev) {
- list_del_init(&dev->node);
+ if (dev)
device_unregister(dev);
- }
}
EXPORT_SYMBOL_GPL(device_destroy);
--
1.4.0
next prev parent reply other threads:[~2006-06-23 6:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-23 5:57 [GIT PATCH] USB fixes for suspend issues Greg KH
2006-06-23 5:58 ` [PATCH 1/2] [PATCH] USB: get USB suspend to work again Greg KH
2006-06-23 5:58 ` Greg KH [this message]
2006-06-23 6:27 ` [GIT PATCH] USB fixes for suspend issues Linus Torvalds
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=11510423183635-git-send-email-greg@kroah.com \
--to=greg@kroah.com \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb-devel@lists.sourceforge.net \
/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