[PATCH 08/10] driver core: Implement tagged directory support for device classes.

Previous thread: [PATCH 07/10] sysfs: Implement sysfs_delete_link and sysfs_rename_link by Benjamin Thery on Monday, June 2, 2008 - 9:45 am. (1 message)

Next thread: [PATCH 09/10] netns: Enable tagging for net_class directories in sysfs by Benjamin Thery on Monday, June 2, 2008 - 9:46 am. (6 messages)
To: Andrew Morton <akpm@...>
Cc: Greg Kroah-Hartman <gregkh@...>, Eric Biederman <ebiederm@...>, Serge Hallyn <serue@...>, <linux-kernel@...>, Tejun Heo <htejun@...>, Al Viro <viro@...>, Daniel Lezcano <dlezcano@...>, Benjamin Thery <benjamin.thery@...>
Date: Monday, June 2, 2008 - 9:45 am

driver core: Implement tagged directory support for device classes.

This patch enables tagging on every class directory if struct class
has tag_ops.

In addition device_del and device_rename were modified to use
sysfs_delete_link and sysfs_rename_link respectively to ensure
when these operations happen on devices whose classes have
tag_ops that they work properly.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Benjamin Thery <benjamin.thery@bull.net>
---
drivers/base/class.c | 30 ++++++++++++++++++++++++++----
drivers/base/core.c | 41 ++++++++++++++++++++++-------------------
include/linux/device.h | 2 ++
3 files changed, 50 insertions(+), 23 deletions(-)

Index: linux-mm/drivers/base/class.c
===================================================================
--- linux-mm.orig/drivers/base/class.c
+++ linux-mm/drivers/base/class.c
@@ -134,6 +134,17 @@ static void remove_class_attrs(struct cl
}
}

+static int class_setup_tagging(struct class *cls)
+{
+ const struct sysfs_tagged_dir_operations *tag_ops;
+
+ tag_ops = cls->tag_ops;
+ if (!tag_ops)
+ return 0;
+
+ return sysfs_enable_tagging(&cls->subsys.kobj, tag_ops);
+}
+
int class_register(struct class *cls)
{
int error;
@@ -162,11 +173,22 @@ int class_register(struct class *cls)
cls->subsys.kobj.ktype = &class_ktype;

error = kset_register(&cls->subsys);
- if (!error) {
- error = add_class_attrs(class_get(cls));
- class_put(cls);
- }
+ if (error)
+ goto out;
+
+ error = class_setup_tagging(cls);
+ if (error)
+ goto out_unregister;
+
+ error = add_class_attrs(cls);
+ if (error)
+ goto out_unregister;
+
+out:
return error;
+out_unregister:
+ kset_unregister(&cls->subsys);
+ goto out;
}

void class_unregister(struct class *cls)
Index: linux-mm/drivers/base/core.c
===================================================================
--- linux-mm.orig/drivers/base/core.c
+++ linux-mm/drivers/...

Previous thread: [PATCH 07/10] sysfs: Implement sysfs_delete_link and sysfs_rename_link by Benjamin Thery on Monday, June 2, 2008 - 9:45 am. (1 message)

Next thread: [PATCH 09/10] netns: Enable tagging for net_class directories in sysfs by Benjamin Thery on Monday, June 2, 2008 - 9:46 am. (6 messages)