foo_obj
struct foo_obj *foo;
static ssize_t foo_show(struct foo_obj *foo_obj, const struct foo_attribute *attr,
return sysfs_emit(buf, "%d\n", foo_obj->foo);
static ssize_t foo_store(struct foo_obj *foo_obj, const struct foo_attribute *attr,
ret = kstrtoint(buf, 10, &foo_obj->foo);
static ssize_t b_show(struct foo_obj *foo_obj, const struct foo_attribute *attr,
var = foo_obj->baz;
var = foo_obj->bar;
static ssize_t b_store(struct foo_obj *foo_obj, const struct foo_attribute *attr,
foo_obj->baz = var;
foo_obj->bar = var;
static struct foo_obj *foo_obj;
static struct foo_obj *bar_obj;
static struct foo_obj *baz_obj;
static struct foo_obj *create_foo_obj(const char *name)
struct foo_obj *foo;
static void destroy_foo_obj(struct foo_obj *foo)
foo_obj = create_foo_obj("foo");
if (!foo_obj)
destroy_foo_obj(foo_obj);
destroy_foo_obj(foo_obj);
#define to_foo_obj(x) container_of(x, struct foo_obj, kobj)
ssize_t (*show)(struct foo_obj *foo, const struct foo_attribute *attr, char *buf);
ssize_t (*store)(struct foo_obj *foo, const struct foo_attribute *attr,
struct foo_obj *foo;
struct foo_obj *foo;