class: Implement support for class attrs in tagged sysfs directories.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
487505c257
commit
672d82c18d
|
@ -47,6 +47,18 @@ static ssize_t class_attr_store(struct kobject *kobj, struct attribute *attr,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const void *class_attr_namespace(struct kobject *kobj,
|
||||||
|
const struct attribute *attr)
|
||||||
|
{
|
||||||
|
struct class_attribute *class_attr = to_class_attr(attr);
|
||||||
|
struct subsys_private *cp = to_subsys_private(kobj);
|
||||||
|
const void *ns = NULL;
|
||||||
|
|
||||||
|
if (class_attr->namespace)
|
||||||
|
ns = class_attr->namespace(cp->class, class_attr);
|
||||||
|
return ns;
|
||||||
|
}
|
||||||
|
|
||||||
static void class_release(struct kobject *kobj)
|
static void class_release(struct kobject *kobj)
|
||||||
{
|
{
|
||||||
struct subsys_private *cp = to_subsys_private(kobj);
|
struct subsys_private *cp = to_subsys_private(kobj);
|
||||||
|
@ -74,6 +86,7 @@ static const struct kobj_ns_type_operations *class_child_ns_type(struct kobject
|
||||||
static const struct sysfs_ops class_sysfs_ops = {
|
static const struct sysfs_ops class_sysfs_ops = {
|
||||||
.show = class_attr_show,
|
.show = class_attr_show,
|
||||||
.store = class_attr_store,
|
.store = class_attr_store,
|
||||||
|
.namespace = class_attr_namespace,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct kobj_type class_ktype = {
|
static struct kobj_type class_ktype = {
|
||||||
|
|
|
@ -350,6 +350,8 @@ struct class_attribute {
|
||||||
char *buf);
|
char *buf);
|
||||||
ssize_t (*store)(struct class *class, struct class_attribute *attr,
|
ssize_t (*store)(struct class *class, struct class_attribute *attr,
|
||||||
const char *buf, size_t count);
|
const char *buf, size_t count);
|
||||||
|
const void *(*namespace)(struct class *class,
|
||||||
|
const struct class_attribute *attr);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CLASS_ATTR(_name, _mode, _show, _store) \
|
#define CLASS_ATTR(_name, _mode, _show, _store) \
|
||||||
|
|
Loading…
Reference in New Issue