summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2007-11-02 15:47:53 +0300
committerGreg Kroah-Hartman <gregkh@suse.de>2008-01-25 07:40:18 +0300
commit23b5212cc7422f475b82124334b64277b5b43013 (patch)
tree15be8d1e0f9600d87d28244de865c60e80b3389c /lib
parent6dcec2511ff55b4abaca7ad3433011a7c04c2430 (diff)
downloadlinux-23b5212cc7422f475b82124334b64277b5b43013.tar.xz
Driver Core: add kobj_attribute handling
Add kobj_sysfs_ops to replace subsys_sysfs_ops. There is no need for special kset operations, we want to be able to use simple attribute operations at any kobject, not only ksets. The whole concept of any default sysfs attribute operations will go away with the upcoming removal of subsys_sysfs_ops. Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/kobject.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/kobject.c b/lib/kobject.c
index 67c3d38d48f0..1c343fe4ba63 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -697,6 +697,35 @@ void kset_init(struct kset * k)
spin_lock_init(&k->list_lock);
}
+/* default kobject attribute operations */
+static ssize_t kobj_attr_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
+{
+ struct kobj_attribute *kattr;
+ ssize_t ret = -EIO;
+
+ kattr = container_of(attr, struct kobj_attribute, attr);
+ if (kattr->show)
+ ret = kattr->show(kobj, kattr, buf);
+ return ret;
+}
+
+static ssize_t kobj_attr_store(struct kobject *kobj, struct attribute *attr,
+ const char *buf, size_t count)
+{
+ struct kobj_attribute *kattr;
+ ssize_t ret = -EIO;
+
+ kattr = container_of(attr, struct kobj_attribute, attr);
+ if (kattr->store)
+ ret = kattr->store(kobj, kattr, buf, count);
+ return ret;
+}
+
+struct sysfs_ops kobj_sysfs_ops = {
+ .show = kobj_attr_show,
+ .store = kobj_attr_store,
+};
/**
* kset_add - add a kset object to the hierarchy.