aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/class.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2011-12-14 17:29:38 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2011-12-14 17:29:38 -0500
commitca22e56debc57b47c422b749c93217ba62644be2 (patch)
treebb2da058ddc05f8cde1161a60f7fdce9620c63ff /drivers/base/class.c
parent6261ddee70174372d6a75601f40719b7a5392f3f (diff)
driver-core: implement 'sysdev' functionality for regular devices and buses
All sysdev classes and sysdev devices will converted to regular devices and buses to properly hook userspace into the event processing. There is no interesting difference between a 'sysdev' and 'device' which would justify to roll an entire own subsystem with different userspace export semantics. Userspace relies on events and generic sysfs subsystem infrastructure from sysdev devices, which are currently not properly available. Every converted sysdev class will create a regular device with the class name in /sys/devices/system and all registered devices will becom a children of theses devices. For compatibility reasons, the sysdev class-wide attributes are created at this parent device. (Do not copy that logic for anything new, subsystem- wide properties belong to the subsystem, not to some fake parent device created in /sys/devices.) Every sysdev driver is implemented as a simple subsystem interface now, and no longer called a driver. After all sysdev classes are ported to regular driver core entities, the sysdev implementation will be entirely removed from the kernel. Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/class.c')
-rw-r--r--drivers/base/class.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/base/class.c b/drivers/base/class.c
index b80d91cc8c3a..03243d4002fd 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -184,9 +184,9 @@ int __class_register(struct class *cls, struct lock_class_key *key)
184 if (!cp) 184 if (!cp)
185 return -ENOMEM; 185 return -ENOMEM;
186 klist_init(&cp->klist_devices, klist_class_dev_get, klist_class_dev_put); 186 klist_init(&cp->klist_devices, klist_class_dev_get, klist_class_dev_put);
187 INIT_LIST_HEAD(&cp->class_interfaces); 187 INIT_LIST_HEAD(&cp->interfaces);
188 kset_init(&cp->glue_dirs); 188 kset_init(&cp->glue_dirs);
189 __mutex_init(&cp->class_mutex, "struct class mutex", key); 189 __mutex_init(&cp->mutex, "subsys mutex", key);
190 error = kobject_set_name(&cp->subsys.kobj, "%s", cls->name); 190 error = kobject_set_name(&cp->subsys.kobj, "%s", cls->name);
191 if (error) { 191 if (error) {
192 kfree(cp); 192 kfree(cp);
@@ -460,15 +460,15 @@ int class_interface_register(struct class_interface *class_intf)
460 if (!parent) 460 if (!parent)
461 return -EINVAL; 461 return -EINVAL;
462 462
463 mutex_lock(&parent->p->class_mutex); 463 mutex_lock(&parent->p->mutex);
464 list_add_tail(&class_intf->node, &parent->p->class_interfaces); 464 list_add_tail(&class_intf->node, &parent->p->interfaces);
465 if (class_intf->add_dev) { 465 if (class_intf->add_dev) {
466 class_dev_iter_init(&iter, parent, NULL, NULL); 466 class_dev_iter_init(&iter, parent, NULL, NULL);
467 while ((dev = class_dev_iter_next(&iter))) 467 while ((dev = class_dev_iter_next(&iter)))
468 class_intf->add_dev(dev, class_intf); 468 class_intf->add_dev(dev, class_intf);
469 class_dev_iter_exit(&iter); 469 class_dev_iter_exit(&iter);
470 } 470 }
471 mutex_unlock(&parent->p->class_mutex); 471 mutex_unlock(&parent->p->mutex);
472 472
473 return 0; 473 return 0;
474} 474}
@@ -482,7 +482,7 @@ void class_interface_unregister(struct class_interface *class_intf)
482 if (!parent) 482 if (!parent)
483 return; 483 return;
484 484
485 mutex_lock(&parent->p->class_mutex); 485 mutex_lock(&parent->p->mutex);
486 list_del_init(&class_intf->node); 486 list_del_init(&class_intf->node);
487 if (class_intf->remove_dev) { 487 if (class_intf->remove_dev) {
488 class_dev_iter_init(&iter, parent, NULL, NULL); 488 class_dev_iter_init(&iter, parent, NULL, NULL);
@@ -490,7 +490,7 @@ void class_interface_unregister(struct class_interface *class_intf)
490 class_intf->remove_dev(dev, class_intf); 490 class_intf->remove_dev(dev, class_intf);
491 class_dev_iter_exit(&iter); 491 class_dev_iter_exit(&iter);
492 } 492 }
493 mutex_unlock(&parent->p->class_mutex); 493 mutex_unlock(&parent->p->mutex);
494 494
495 class_put(parent); 495 class_put(parent);
496} 496}