diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2006-06-22 20:17:32 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-06-23 01:54:30 -0400 |
commit | 5d9fd169c9fbdaecdc430431e59bf94ff40b93d3 (patch) | |
tree | 11afe01918373ecbfe9097b084a1cc88d706f1a4 /drivers/base/core.c | |
parent | 0517587e5896cef1d5f99d3b24f5f2ca15d952ad (diff) |
[PATCH] Driver core: fix locking issues with the devices that are attached to classes
Doh, that was foolish...
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r-- | 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 d0f84ff78776..27c2176895de 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -356,6 +356,13 @@ int device_add(struct device *dev) | |||
356 | if (parent) | 356 | if (parent) |
357 | klist_add_tail(&dev->knode_parent, &parent->klist_children); | 357 | klist_add_tail(&dev->knode_parent, &parent->klist_children); |
358 | 358 | ||
359 | if (dev->class) { | ||
360 | /* tie the class to the device */ | ||
361 | down(&dev->class->sem); | ||
362 | list_add_tail(&dev->node, &dev->class->devices); | ||
363 | up(&dev->class->sem); | ||
364 | } | ||
365 | |||
359 | /* notify platform of device entry */ | 366 | /* notify platform of device entry */ |
360 | if (platform_notify) | 367 | if (platform_notify) |
361 | platform_notify(dev); | 368 | platform_notify(dev); |
@@ -455,6 +462,9 @@ void device_del(struct device * dev) | |||
455 | sysfs_remove_link(&dev->kobj, "device"); | 462 | sysfs_remove_link(&dev->kobj, "device"); |
456 | sysfs_remove_link(&dev->parent->kobj, class_name); | 463 | sysfs_remove_link(&dev->parent->kobj, class_name); |
457 | kfree(class_name); | 464 | kfree(class_name); |
465 | down(&dev->class->sem); | ||
466 | list_del_init(&dev->node); | ||
467 | up(&dev->class->sem); | ||
458 | } | 468 | } |
459 | device_remove_file(dev, &dev->uevent_attr); | 469 | device_remove_file(dev, &dev->uevent_attr); |
460 | 470 | ||
@@ -601,11 +611,6 @@ struct device *device_create(struct class *class, struct device *parent, | |||
601 | if (retval) | 611 | if (retval) |
602 | goto error; | 612 | goto error; |
603 | 613 | ||
604 | /* tie the class to the device */ | ||
605 | down(&class->sem); | ||
606 | list_add_tail(&dev->node, &class->devices); | ||
607 | up(&class->sem); | ||
608 | |||
609 | return dev; | 614 | return dev; |
610 | 615 | ||
611 | error: | 616 | error: |
@@ -636,9 +641,7 @@ void device_destroy(struct class *class, dev_t devt) | |||
636 | } | 641 | } |
637 | up(&class->sem); | 642 | up(&class->sem); |
638 | 643 | ||
639 | if (dev) { | 644 | if (dev) |
640 | list_del_init(&dev->node); | ||
641 | device_unregister(dev); | 645 | device_unregister(dev); |
642 | } | ||
643 | } | 646 | } |
644 | EXPORT_SYMBOL_GPL(device_destroy); | 647 | EXPORT_SYMBOL_GPL(device_destroy); |