diff options
-rw-r--r-- | drivers/base/class.c | 17 | ||||
-rw-r--r-- | include/linux/device.h | 2 |
2 files changed, 17 insertions, 2 deletions
diff --git a/drivers/base/class.c b/drivers/base/class.c index 4f1df2e8fd74..b80d91cc8c3a 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -47,6 +47,18 @@ static ssize_t class_attr_store(struct kobject *kobj, struct attribute *attr, | |||
47 | return ret; | 47 | return ret; |
48 | } | 48 | } |
49 | 49 | ||
50 | static const void *class_attr_namespace(struct kobject *kobj, | ||
51 | const struct attribute *attr) | ||
52 | { | ||
53 | struct class_attribute *class_attr = to_class_attr(attr); | ||
54 | struct subsys_private *cp = to_subsys_private(kobj); | ||
55 | const void *ns = NULL; | ||
56 | |||
57 | if (class_attr->namespace) | ||
58 | ns = class_attr->namespace(cp->class, class_attr); | ||
59 | return ns; | ||
60 | } | ||
61 | |||
50 | static void class_release(struct kobject *kobj) | 62 | static void class_release(struct kobject *kobj) |
51 | { | 63 | { |
52 | struct subsys_private *cp = to_subsys_private(kobj); | 64 | struct subsys_private *cp = to_subsys_private(kobj); |
@@ -72,8 +84,9 @@ static const struct kobj_ns_type_operations *class_child_ns_type(struct kobject | |||
72 | } | 84 | } |
73 | 85 | ||
74 | static const struct sysfs_ops class_sysfs_ops = { | 86 | static const struct sysfs_ops class_sysfs_ops = { |
75 | .show = class_attr_show, | 87 | .show = class_attr_show, |
76 | .store = class_attr_store, | 88 | .store = class_attr_store, |
89 | .namespace = class_attr_namespace, | ||
77 | }; | 90 | }; |
78 | 91 | ||
79 | static struct kobj_type class_ktype = { | 92 | static struct kobj_type class_ktype = { |
diff --git a/include/linux/device.h b/include/linux/device.h index c20dfbfc49b4..ea70bb2e6878 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -350,6 +350,8 @@ struct class_attribute { | |||
350 | char *buf); | 350 | char *buf); |
351 | ssize_t (*store)(struct class *class, struct class_attribute *attr, | 351 | ssize_t (*store)(struct class *class, struct class_attribute *attr, |
352 | const char *buf, size_t count); | 352 | const char *buf, size_t count); |
353 | const void *(*namespace)(struct class *class, | ||
354 | const struct class_attribute *attr); | ||
353 | }; | 355 | }; |
354 | 356 | ||
355 | #define CLASS_ATTR(_name, _mode, _show, _store) \ | 357 | #define CLASS_ATTR(_name, _mode, _show, _store) \ |