diff options
Diffstat (limited to 'drivers/cpuidle/sysfs.c')
-rw-r--r-- | drivers/cpuidle/sysfs.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c index be7917ec40c9..1e756e160dca 100644 --- a/drivers/cpuidle/sysfs.c +++ b/drivers/cpuidle/sysfs.c | |||
@@ -216,7 +216,8 @@ static struct kobj_type ktype_cpuidle = { | |||
216 | 216 | ||
217 | struct cpuidle_state_attr { | 217 | struct cpuidle_state_attr { |
218 | struct attribute attr; | 218 | struct attribute attr; |
219 | ssize_t (*show)(struct cpuidle_state *, char *); | 219 | ssize_t (*show)(struct cpuidle_state *, \ |
220 | struct cpuidle_state_usage *, char *); | ||
220 | ssize_t (*store)(struct cpuidle_state *, const char *, size_t); | 221 | ssize_t (*store)(struct cpuidle_state *, const char *, size_t); |
221 | }; | 222 | }; |
222 | 223 | ||
@@ -224,19 +225,22 @@ struct cpuidle_state_attr { | |||
224 | static struct cpuidle_state_attr attr_##_name = __ATTR(_name, 0444, show, NULL) | 225 | static struct cpuidle_state_attr attr_##_name = __ATTR(_name, 0444, show, NULL) |
225 | 226 | ||
226 | #define define_show_state_function(_name) \ | 227 | #define define_show_state_function(_name) \ |
227 | static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ | 228 | static ssize_t show_state_##_name(struct cpuidle_state *state, \ |
229 | struct cpuidle_state_usage *state_usage, char *buf) \ | ||
228 | { \ | 230 | { \ |
229 | return sprintf(buf, "%u\n", state->_name);\ | 231 | return sprintf(buf, "%u\n", state->_name);\ |
230 | } | 232 | } |
231 | 233 | ||
232 | #define define_show_state_ull_function(_name) \ | 234 | #define define_show_state_ull_function(_name) \ |
233 | static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ | 235 | static ssize_t show_state_##_name(struct cpuidle_state *state, \ |
236 | struct cpuidle_state_usage *state_usage, char *buf) \ | ||
234 | { \ | 237 | { \ |
235 | return sprintf(buf, "%llu\n", state->_name);\ | 238 | return sprintf(buf, "%llu\n", state_usage->_name);\ |
236 | } | 239 | } |
237 | 240 | ||
238 | #define define_show_state_str_function(_name) \ | 241 | #define define_show_state_str_function(_name) \ |
239 | static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ | 242 | static ssize_t show_state_##_name(struct cpuidle_state *state, \ |
243 | struct cpuidle_state_usage *state_usage, char *buf) \ | ||
240 | { \ | 244 | { \ |
241 | if (state->_name[0] == '\0')\ | 245 | if (state->_name[0] == '\0')\ |
242 | return sprintf(buf, "<null>\n");\ | 246 | return sprintf(buf, "<null>\n");\ |
@@ -269,16 +273,18 @@ static struct attribute *cpuidle_state_default_attrs[] = { | |||
269 | 273 | ||
270 | #define kobj_to_state_obj(k) container_of(k, struct cpuidle_state_kobj, kobj) | 274 | #define kobj_to_state_obj(k) container_of(k, struct cpuidle_state_kobj, kobj) |
271 | #define kobj_to_state(k) (kobj_to_state_obj(k)->state) | 275 | #define kobj_to_state(k) (kobj_to_state_obj(k)->state) |
276 | #define kobj_to_state_usage(k) (kobj_to_state_obj(k)->state_usage) | ||
272 | #define attr_to_stateattr(a) container_of(a, struct cpuidle_state_attr, attr) | 277 | #define attr_to_stateattr(a) container_of(a, struct cpuidle_state_attr, attr) |
273 | static ssize_t cpuidle_state_show(struct kobject * kobj, | 278 | static ssize_t cpuidle_state_show(struct kobject * kobj, |
274 | struct attribute * attr ,char * buf) | 279 | struct attribute * attr ,char * buf) |
275 | { | 280 | { |
276 | int ret = -EIO; | 281 | int ret = -EIO; |
277 | struct cpuidle_state *state = kobj_to_state(kobj); | 282 | struct cpuidle_state *state = kobj_to_state(kobj); |
283 | struct cpuidle_state_usage *state_usage = kobj_to_state_usage(kobj); | ||
278 | struct cpuidle_state_attr * cattr = attr_to_stateattr(attr); | 284 | struct cpuidle_state_attr * cattr = attr_to_stateattr(attr); |
279 | 285 | ||
280 | if (cattr->show) | 286 | if (cattr->show) |
281 | ret = cattr->show(state, buf); | 287 | ret = cattr->show(state, state_usage, buf); |
282 | 288 | ||
283 | return ret; | 289 | return ret; |
284 | } | 290 | } |
@@ -316,13 +322,15 @@ int cpuidle_add_state_sysfs(struct cpuidle_device *device) | |||
316 | { | 322 | { |
317 | int i, ret = -ENOMEM; | 323 | int i, ret = -ENOMEM; |
318 | struct cpuidle_state_kobj *kobj; | 324 | struct cpuidle_state_kobj *kobj; |
325 | struct cpuidle_driver *drv = cpuidle_get_driver(); | ||
319 | 326 | ||
320 | /* state statistics */ | 327 | /* state statistics */ |
321 | for (i = 0; i < device->state_count; i++) { | 328 | for (i = 0; i < device->state_count; i++) { |
322 | kobj = kzalloc(sizeof(struct cpuidle_state_kobj), GFP_KERNEL); | 329 | kobj = kzalloc(sizeof(struct cpuidle_state_kobj), GFP_KERNEL); |
323 | if (!kobj) | 330 | if (!kobj) |
324 | goto error_state; | 331 | goto error_state; |
325 | kobj->state = &device->states[i]; | 332 | kobj->state = &drv->states[i]; |
333 | kobj->state_usage = &device->states_usage[i]; | ||
326 | init_completion(&kobj->kobj_unregister); | 334 | init_completion(&kobj->kobj_unregister); |
327 | 335 | ||
328 | ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle, &device->kobj, | 336 | ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle, &device->kobj, |