aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r--drivers/base/core.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index b90ae6f7be86..c05b1159023e 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -21,6 +21,7 @@
21#include <linux/genhd.h> 21#include <linux/genhd.h>
22#include <linux/kallsyms.h> 22#include <linux/kallsyms.h>
23#include <linux/semaphore.h> 23#include <linux/semaphore.h>
24#include <linux/mutex.h>
24 25
25#include "base.h" 26#include "base.h"
26#include "power/power.h" 27#include "power/power.h"
@@ -907,7 +908,7 @@ int device_add(struct device *dev)
907 klist_add_tail(&dev->knode_parent, &parent->klist_children); 908 klist_add_tail(&dev->knode_parent, &parent->klist_children);
908 909
909 if (dev->class) { 910 if (dev->class) {
910 down(&dev->class->p->class_sem); 911 mutex_lock(&dev->class->p->class_mutex);
911 /* tie the class to the device */ 912 /* tie the class to the device */
912 list_add_tail(&dev->node, &dev->class->p->class_devices); 913 list_add_tail(&dev->node, &dev->class->p->class_devices);
913 914
@@ -916,7 +917,7 @@ int device_add(struct device *dev)
916 &dev->class->p->class_interfaces, node) 917 &dev->class->p->class_interfaces, node)
917 if (class_intf->add_dev) 918 if (class_intf->add_dev)
918 class_intf->add_dev(dev, class_intf); 919 class_intf->add_dev(dev, class_intf);
919 up(&dev->class->p->class_sem); 920 mutex_unlock(&dev->class->p->class_mutex);
920 } 921 }
921 Done: 922 Done:
922 put_device(dev); 923 put_device(dev);
@@ -1017,7 +1018,7 @@ void device_del(struct device *dev)
1017 if (dev->class) { 1018 if (dev->class) {
1018 device_remove_class_symlinks(dev); 1019 device_remove_class_symlinks(dev);
1019 1020
1020 down(&dev->class->p->class_sem); 1021 mutex_lock(&dev->class->p->class_mutex);
1021 /* notify any interfaces that the device is now gone */ 1022 /* notify any interfaces that the device is now gone */
1022 list_for_each_entry(class_intf, 1023 list_for_each_entry(class_intf,
1023 &dev->class->p->class_interfaces, node) 1024 &dev->class->p->class_interfaces, node)
@@ -1025,7 +1026,7 @@ void device_del(struct device *dev)
1025 class_intf->remove_dev(dev, class_intf); 1026 class_intf->remove_dev(dev, class_intf);
1026 /* remove the device from the class list */ 1027 /* remove the device from the class list */
1027 list_del_init(&dev->node); 1028 list_del_init(&dev->node);
1028 up(&dev->class->p->class_sem); 1029 mutex_unlock(&dev->class->p->class_mutex);
1029 } 1030 }
1030 device_remove_file(dev, &uevent_attr); 1031 device_remove_file(dev, &uevent_attr);
1031 device_remove_attrs(dev); 1032 device_remove_attrs(dev);