Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 75761
b: refs/heads/master
c: 23b5212
h: refs/heads/master
i:
  75759: a813a74
v: v3
  • Loading branch information
Kay Sievers authored and Greg Kroah-Hartman committed Jan 25, 2008
1 parent 6b3711b commit 41efb2d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6dcec2511ff55b4abaca7ad3433011a7c04c2430
refs/heads/master: 23b5212cc7422f475b82124334b64277b5b43013
10 changes: 10 additions & 0 deletions trunk/include/linux/kobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ struct kset_uevent_ops {
struct kobj_uevent_env *env);
};

struct kobj_attribute {
struct attribute attr;
ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,
char *buf);
ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t count);
};

extern struct sysfs_ops kobj_sysfs_ops;

/**
* struct kset - a set of kobjects of a specific type, belonging to a specific subsystem.
*
Expand Down
29 changes: 29 additions & 0 deletions trunk/lib/kobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 41efb2d

Please sign in to comment.