aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/class.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base/class.c')
-rw-r--r--drivers/base/class.c22
1 files changed, 11 insertions, 11 deletions
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}