kset-example.c (ecd740c6f2f092b90b95fa35f757973589eaaca2) kset-example.c (de5109898a8a0cb001abcb6916bef4efa32bf39b)
1/*
2 * Sample kset and ktype implementation
3 *
4 * Copyright (C) 2004-2007 Greg Kroah-Hartman <greg@kroah.com>
5 * Copyright (C) 2007 Novell Inc.
6 *
7 * Released under the GPL version 2 only.
8 *

--- 110 unchanged lines hidden (view full) ---

119
120static ssize_t foo_store(struct foo_obj *foo_obj, struct foo_attribute *attr,
121 const char *buf, size_t count)
122{
123 sscanf(buf, "%du", &foo_obj->foo);
124 return count;
125}
126
1/*
2 * Sample kset and ktype implementation
3 *
4 * Copyright (C) 2004-2007 Greg Kroah-Hartman <greg@kroah.com>
5 * Copyright (C) 2007 Novell Inc.
6 *
7 * Released under the GPL version 2 only.
8 *

--- 110 unchanged lines hidden (view full) ---

119
120static ssize_t foo_store(struct foo_obj *foo_obj, struct foo_attribute *attr,
121 const char *buf, size_t count)
122{
123 sscanf(buf, "%du", &foo_obj->foo);
124 return count;
125}
126
127/* Sysfs attributes cannot be world-writable. */
127static struct foo_attribute foo_attribute =
128static struct foo_attribute foo_attribute =
128 __ATTR(foo, 0666, foo_show, foo_store);
129 __ATTR(foo, 0664, foo_show, foo_store);
129
130/*
131 * More complex function where we determine which variable is being accessed by
132 * looking at the attribute for the "baz" and "bar" files.
133 */
134static ssize_t b_show(struct foo_obj *foo_obj, struct foo_attribute *attr,
135 char *buf)
136{

--- 15 unchanged lines hidden (view full) ---

152 if (strcmp(attr->attr.name, "baz") == 0)
153 foo_obj->baz = var;
154 else
155 foo_obj->bar = var;
156 return count;
157}
158
159static struct foo_attribute baz_attribute =
130
131/*
132 * More complex function where we determine which variable is being accessed by
133 * looking at the attribute for the "baz" and "bar" files.
134 */
135static ssize_t b_show(struct foo_obj *foo_obj, struct foo_attribute *attr,
136 char *buf)
137{

--- 15 unchanged lines hidden (view full) ---

153 if (strcmp(attr->attr.name, "baz") == 0)
154 foo_obj->baz = var;
155 else
156 foo_obj->bar = var;
157 return count;
158}
159
160static struct foo_attribute baz_attribute =
160 __ATTR(baz, 0666, b_show, b_store);
161 __ATTR(baz, 0664, b_show, b_store);
161static struct foo_attribute bar_attribute =
162static struct foo_attribute bar_attribute =
162 __ATTR(bar, 0666, b_show, b_store);
163 __ATTR(bar, 0664, b_show, b_store);
163
164/*
165 * Create a group of attributes so that we can create and destroy them all
166 * at once.
167 */
168static struct attribute *foo_default_attrs[] = {
169 &foo_attribute.attr,
170 &baz_attribute.attr,

--- 110 unchanged lines hidden ---
164
165/*
166 * Create a group of attributes so that we can create and destroy them all
167 * at once.
168 */
169static struct attribute *foo_default_attrs[] = {
170 &foo_attribute.attr,
171 &baz_attribute.attr,

--- 110 unchanged lines hidden ---