[PATCH 1/3] device class: add symlink creation helpers

From: Jani Nikula
Date: Wed Dec 09 2009 - 08:50:36 EST


From: Artem Bityutskiy <Artem.Bityutskiy@xxxxxxxxx>

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@xxxxxxxxx>
---
drivers/base/class.c | 21 +++++++++++++++++++++
include/linux/device.h | 4 ++++
2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/drivers/base/class.c b/drivers/base/class.c
index 161746d..818cbe2 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -92,6 +92,25 @@ void class_remove_file(struct class *cls, const struct class_attribute *attr)
sysfs_remove_file(&cls->p->class_subsys.kobj, &attr->attr);
}

+int class_create_link(struct class *cls, struct kobject *target,
+ const char *name)
+{
+ int error;
+
+ if (cls)
+ error = sysfs_create_link(&cls->p->class_subsys.kobj,
+ target, name);
+ else
+ error = -EINVAL;
+ return error;
+}
+
+void class_remove_link(struct class *cls, const char *name)
+{
+ if (cls)
+ sysfs_remove_link(&cls->p->class_subsys.kobj, name);
+}
+
static struct class *class_get(struct class *cls)
{
if (cls)
@@ -585,6 +604,8 @@ int __init classes_init(void)

EXPORT_SYMBOL_GPL(class_create_file);
EXPORT_SYMBOL_GPL(class_remove_file);
+EXPORT_SYMBOL_GPL(class_create_link);
+EXPORT_SYMBOL_GPL(class_remove_link);
EXPORT_SYMBOL_GPL(class_unregister);
EXPORT_SYMBOL_GPL(class_destroy);

diff --git a/include/linux/device.h b/include/linux/device.h
index 2ea3e49..e877be6 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -262,6 +262,10 @@ extern int __must_check class_create_file(struct class *class,
const struct class_attribute *attr);
extern void class_remove_file(struct class *class,
const struct class_attribute *attr);
+extern int __must_check class_create_link(struct class *class,
+ struct kobject *target,
+ const char *name);
+extern void class_remove_link(struct class *class, const char *name);

struct class_interface {
struct list_head node;
--
1.6.5.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/