aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/base.h4
-rw-r--r--drivers/base/class.c22
-rw-r--r--drivers/base/core.c8
3 files changed, 17 insertions, 17 deletions
diff --git a/drivers/base/base.h b/drivers/base/base.h
index a77d4bd2ea63..4435732437a5 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -45,7 +45,7 @@ struct driver_private {
45 * @class_devices - list of devices associated with this class 45 * @class_devices - list of devices associated with this class
46 * @class_interfaces - list of class_interfaces associated with this class 46 * @class_interfaces - list of class_interfaces associated with this class
47 * @class_dirs - 47 * @class_dirs -
48 * @sem - semaphore to protect the children, devices, and interfaces lists. 48 * @class_sem - semaphore to protect the children, devices, and interfaces lists.
49 * @class - pointer back to the struct class that this structure is associated 49 * @class - pointer back to the struct class that this structure is associated
50 * with. 50 * with.
51 * 51 *
@@ -58,7 +58,7 @@ struct class_private {
58 struct list_head class_devices; 58 struct list_head class_devices;
59 struct list_head class_interfaces; 59 struct list_head class_interfaces;
60 struct kset class_dirs; 60 struct kset class_dirs;
61 struct semaphore sem; 61 struct semaphore class_sem;
62 struct class *class; 62 struct class *class;
63}; 63};
64#define to_class(obj) \ 64#define to_class(obj) \
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 86778b86496e..d24d21114ccb 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -147,7 +147,7 @@ int class_register(struct class *cls)
147 INIT_LIST_HEAD(&cp->class_devices); 147 INIT_LIST_HEAD(&cp->class_devices);
148 INIT_LIST_HEAD(&cp->class_interfaces); 148 INIT_LIST_HEAD(&cp->class_interfaces);
149 kset_init(&cp->class_dirs); 149 kset_init(&cp->class_dirs);
150 init_MUTEX(&cp->sem); 150 init_MUTEX(&cp->class_sem);
151 error = kobject_set_name(&cp->class_subsys.kobj, "%s", cls->name); 151 error = kobject_set_name(&cp->class_subsys.kobj, "%s", cls->name);
152 if (error) { 152 if (error) {
153 kfree(cp); 153 kfree(cp);
@@ -278,7 +278,7 @@ char *make_class_name(const char *name, struct kobject *kobj)
278 * We check the return of @fn each time. If it returns anything 278 * We check the return of @fn each time. If it returns anything
279 * other than 0, we break out and return that value. 279 * other than 0, we break out and return that value.
280 * 280 *
281 * Note, we hold class->sem in this function, so it can not be 281 * Note, we hold class->class_sem in this function, so it can not be
282 * re-acquired in @fn, otherwise it will self-deadlocking. For 282 * re-acquired in @fn, otherwise it will self-deadlocking. For
283 * example, calls to add or remove class members would be verboten. 283 * example, calls to add or remove class members would be verboten.
284 */ 284 */
@@ -290,7 +290,7 @@ int class_for_each_device(struct class *class, struct device *start,
290 290
291 if (!class) 291 if (!class)
292 return -EINVAL; 292 return -EINVAL;
293 down(&class->p->sem); 293 down(&class->p->class_sem);
294 list_for_each_entry(dev, &class->p->class_devices, node) { 294 list_for_each_entry(dev, &class->p->class_devices, node) {
295 if (start) { 295 if (start) {
296 if (start == dev) 296 if (start == dev)
@@ -303,7 +303,7 @@ int class_for_each_device(struct class *class, struct device *start,
303 if (error) 303 if (error)
304 break; 304 break;
305 } 305 }
306 up(&class->p->sem); 306 up(&class->p->class_sem);
307 307
308 return error; 308 return error;
309} 309}
@@ -326,7 +326,7 @@ EXPORT_SYMBOL_GPL(class_for_each_device);
326 * 326 *
327 * Note, you will need to drop the reference with put_device() after use. 327 * Note, you will need to drop the reference with put_device() after use.
328 * 328 *
329 * We hold class->sem in this function, so it can not be 329 * We hold class->class_sem in this function, so it can not be
330 * re-acquired in @match, otherwise it will self-deadlocking. For 330 * re-acquired in @match, otherwise it will self-deadlocking. For
331 * example, calls to add or remove class members would be verboten. 331 * example, calls to add or remove class members would be verboten.
332 */ 332 */
@@ -340,7 +340,7 @@ struct device *class_find_device(struct class *class, struct device *start,
340 if (!class) 340 if (!class)
341 return NULL; 341 return NULL;
342 342
343 down(&class->p->sem); 343 down(&class->p->class_sem);
344 list_for_each_entry(dev, &class->p->class_devices, node) { 344 list_for_each_entry(dev, &class->p->class_devices, node) {
345 if (start) { 345 if (start) {
346 if (start == dev) 346 if (start == dev)
@@ -354,7 +354,7 @@ struct device *class_find_device(struct class *class, struct device *start,
354 } else 354 } else
355 put_device(dev); 355 put_device(dev);
356 } 356 }
357 up(&class->p->sem); 357 up(&class->p->class_sem);
358 358
359 return found ? dev : NULL; 359 return found ? dev : NULL;
360} 360}
@@ -372,13 +372,13 @@ int class_interface_register(struct class_interface *class_intf)
372 if (!parent) 372 if (!parent)
373 return -EINVAL; 373 return -EINVAL;
374 374
375 down(&parent->p->sem); 375 down(&parent->p->class_sem);
376 list_add_tail(&class_intf->node, &parent->p->class_interfaces); 376 list_add_tail(&class_intf->node, &parent->p->class_interfaces);
377 if (class_intf->add_dev) { 377 if (class_intf->add_dev) {
378 list_for_each_entry(dev, &parent->p->class_devices, node) 378 list_for_each_entry(dev, &parent->p->class_devices, node)
379 class_intf->add_dev(dev, class_intf); 379 class_intf->add_dev(dev, class_intf);
380 } 380 }
381 up(&parent->p->sem); 381 up(&parent->p->class_sem);
382 382
383 return 0; 383 return 0;
384} 384}
@@ -391,13 +391,13 @@ void class_interface_unregister(struct class_interface *class_intf)
391 if (!parent) 391 if (!parent)
392 return; 392 return;
393 393
394 down(&parent->p->sem); 394 down(&parent->p->class_sem);
395 list_del_init(&class_intf->node); 395 list_del_init(&class_intf->node);
396 if (class_intf->remove_dev) { 396 if (class_intf->remove_dev) {
397 list_for_each_entry(dev, &parent->p->class_devices, node) 397 list_for_each_entry(dev, &parent->p->class_devices, node)
398 class_intf->remove_dev(dev, class_intf); 398 class_intf->remove_dev(dev, class_intf);
399 } 399 }
400 up(&parent->p->sem); 400 up(&parent->p->class_sem);
401 401
402 class_put(parent); 402 class_put(parent);
403} 403}
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 6e1cff296d9f..b90ae6f7be86 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -907,7 +907,7 @@ int device_add(struct device *dev)
907 klist_add_tail(&dev->knode_parent, &parent->klist_children); 907 klist_add_tail(&dev->knode_parent, &parent->klist_children);
908 908
909 if (dev->class) { 909 if (dev->class) {
910 down(&dev->class->p->sem); 910 down(&dev->class->p->class_sem);
911 /* tie the class to the device */ 911 /* tie the class to the device */
912 list_add_tail(&dev->node, &dev->class->p->class_devices); 912 list_add_tail(&dev->node, &dev->class->p->class_devices);
913 913
@@ -916,7 +916,7 @@ int device_add(struct device *dev)
916 &dev->class->p->class_interfaces, node) 916 &dev->class->p->class_interfaces, node)
917 if (class_intf->add_dev) 917 if (class_intf->add_dev)
918 class_intf->add_dev(dev, class_intf); 918 class_intf->add_dev(dev, class_intf);
919 up(&dev->class->p->sem); 919 up(&dev->class->p->class_sem);
920 } 920 }
921 Done: 921 Done:
922 put_device(dev); 922 put_device(dev);
@@ -1017,7 +1017,7 @@ void device_del(struct device *dev)
1017 if (dev->class) { 1017 if (dev->class) {
1018 device_remove_class_symlinks(dev); 1018 device_remove_class_symlinks(dev);
1019 1019
1020 down(&dev->class->p->sem); 1020 down(&dev->class->p->class_sem);
1021 /* notify any interfaces that the device is now gone */ 1021 /* notify any interfaces that the device is now gone */
1022 list_for_each_entry(class_intf, 1022 list_for_each_entry(class_intf,
1023 &dev->class->p->class_interfaces, node) 1023 &dev->class->p->class_interfaces, node)
@@ -1025,7 +1025,7 @@ void device_del(struct device *dev)
1025 class_intf->remove_dev(dev, class_intf); 1025 class_intf->remove_dev(dev, class_intf);
1026 /* remove the device from the class list */ 1026 /* remove the device from the class list */
1027 list_del_init(&dev->node); 1027 list_del_init(&dev->node);
1028 up(&dev->class->p->sem); 1028 up(&dev->class->p->class_sem);
1029 } 1029 }
1030 device_remove_file(dev, &uevent_attr); 1030 device_remove_file(dev, &uevent_attr);
1031 device_remove_attrs(dev); 1031 device_remove_attrs(dev);