Lines Matching +full:attribute +full:- +full:set
1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2004-2007 Greg Kroah-Hartman <greg@kroah.com>
37 /* a custom attribute that works just for a struct foo_obj. */
39 struct attribute attr;
53 struct attribute *attr, in foo_attr_show()
56 struct foo_attribute *attribute; in foo_attr_show() local
59 attribute = to_foo_attr(attr); in foo_attr_show()
62 if (!attribute->show) in foo_attr_show()
63 return -EIO; in foo_attr_show()
65 return attribute->show(foo, attribute, buf); in foo_attr_show()
73 struct attribute *attr, in foo_attr_store()
76 struct foo_attribute *attribute; in foo_attr_store() local
79 attribute = to_foo_attr(attr); in foo_attr_store()
82 if (!attribute->store) in foo_attr_store()
83 return -EIO; in foo_attr_store()
85 return attribute->store(foo, attribute, buf, len); in foo_attr_store()
115 return sysfs_emit(buf, "%d\n", foo_obj->foo); in foo_show()
123 ret = kstrtoint(buf, 10, &foo_obj->foo); in foo_store()
130 /* Sysfs attributes cannot be world-writable. */
136 * looking at the attribute for the "baz" and "bar" files.
143 if (strcmp(attr->attr.name, "baz") == 0) in b_show()
144 var = foo_obj->baz; in b_show()
146 var = foo_obj->bar; in b_show()
159 if (strcmp(attr->attr.name, "baz") == 0) in b_store()
160 foo_obj->baz = var; in b_store()
162 foo_obj->bar = var; in b_store()
175 static struct attribute *foo_default_attrs[] = {
185 * release function, and the set of default attributes we want created
210 * As we have a kset for this kobject, we need to set it before calling in create_foo_obj()
213 foo->kobj.kset = example_kset; in create_foo_obj()
218 * kobject, we don't have to set a parent for the kobject, the kobject in create_foo_obj()
221 retval = kobject_init_and_add(&foo->kobj, &foo_ktype, NULL, "%s", name); in create_foo_obj()
223 kobject_put(&foo->kobj); in create_foo_obj()
231 kobject_uevent(&foo->kobj, KOBJ_ADD); in create_foo_obj()
238 kobject_put(&foo->kobj); in destroy_foo_obj()
249 return -ENOMEM; in example_init()
274 return -EINVAL; in example_init()
289 MODULE_AUTHOR("Greg Kroah-Hartman <greg@kroah.com>");