From: Dmitry Torokhov This will allow unclutter /sys/classes directory, combining classes related to the same subsystem "under one roof". Signed-off-by: Dmitry Torokhov Signed-off-by: Andrew Morton --- drivers/base/class.c | 8 +++++++- include/linux/device.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff -puN drivers/base/class.c~driver-core-allow-nesting-classes drivers/base/class.c --- devel/drivers/base/class.c~driver-core-allow-nesting-classes 2005-09-15 20:54:24.000000000 -0700 +++ devel-akpm/drivers/base/class.c 2005-09-15 20:54:24.000000000 -0700 @@ -135,6 +135,7 @@ static void remove_class_attrs(struct cl int class_register(struct class * cls) { + struct class *parent; int error; pr_debug("device class '%s': registering\n", cls->name); @@ -146,7 +147,11 @@ int class_register(struct class * cls) if (error) return error; - subsys_set_kset(cls, class_subsys); + parent = class_get(cls->parent); + if (parent) + subsys_set_kset(cls, parent->subsys); + else + subsys_set_kset(cls, class_subsys); error = subsystem_register(&cls->subsys); if (!error) { @@ -161,6 +166,7 @@ void class_unregister(struct class * cls pr_debug("device class '%s': unregistering\n", cls->name); remove_class_attrs(cls); subsystem_unregister(&cls->subsys); + class_put(cls->parent); } static void class_create_release(struct class *cls) diff -puN include/linux/device.h~driver-core-allow-nesting-classes include/linux/device.h --- devel/include/linux/device.h~driver-core-allow-nesting-classes 2005-09-15 20:54:24.000000000 -0700 +++ devel-akpm/include/linux/device.h 2005-09-15 20:54:24.000000000 -0700 @@ -157,6 +157,7 @@ struct class { struct module * owner; struct subsystem subsys; + struct class * parent; struct list_head children; struct list_head interfaces; struct semaphore sem; /* locks both the children and interfaces lists */ _