aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpuidle/sysfs.c
diff options
context:
space:
mode:
authorShuoX Liu <shuox.liu@intel.com>2012-07-03 13:05:31 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2012-07-03 13:05:31 -0400
commitdc7fd275ae60ef8edf952aff2a62462f5d892fd4 (patch)
tree620ffab8288830c8e8dc03b24e77fe3800d03b7e /drivers/cpuidle/sysfs.c
parent6887a4131da3adaab011613776d865f4bcfb5678 (diff)
cpuidle: move field disable from per-driver to per-cpu
Andrew J.Schorr raises a question. When he changes the disable setting on a single CPU, it affects all the other CPUs. Basically, currently, the disable field is per-driver instead of per-cpu. All the C states of the same driver are shared by all CPU in the same machine. The patch changes the `disable' field to per-cpu, so we could set this separately for each cpu. Signed-off-by: ShuoX Liu <shuox.liu@intel.com> Reported-by: Andrew J.Schorr <aschorr@telemetry-investments.com> Reviewed-by: Yanmin Zhang <yanmin_zhang@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'drivers/cpuidle/sysfs.c')
-rw-r--r--drivers/cpuidle/sysfs.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index 88032b4dc6d2..5f809e337b89 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -217,7 +217,8 @@ struct cpuidle_state_attr {
217 struct attribute attr; 217 struct attribute attr;
218 ssize_t (*show)(struct cpuidle_state *, \ 218 ssize_t (*show)(struct cpuidle_state *, \
219 struct cpuidle_state_usage *, char *); 219 struct cpuidle_state_usage *, char *);
220 ssize_t (*store)(struct cpuidle_state *, const char *, size_t); 220 ssize_t (*store)(struct cpuidle_state *, \
221 struct cpuidle_state_usage *, const char *, size_t);
221}; 222};
222 223
223#define define_one_state_ro(_name, show) \ 224#define define_one_state_ro(_name, show) \
@@ -233,21 +234,22 @@ static ssize_t show_state_##_name(struct cpuidle_state *state, \
233 return sprintf(buf, "%u\n", state->_name);\ 234 return sprintf(buf, "%u\n", state->_name);\
234} 235}
235 236
236#define define_store_state_function(_name) \ 237#define define_store_state_ull_function(_name) \
237static ssize_t store_state_##_name(struct cpuidle_state *state, \ 238static ssize_t store_state_##_name(struct cpuidle_state *state, \
239 struct cpuidle_state_usage *state_usage, \
238 const char *buf, size_t size) \ 240 const char *buf, size_t size) \
239{ \ 241{ \
240 long value; \ 242 unsigned long long value; \
241 int err; \ 243 int err; \
242 if (!capable(CAP_SYS_ADMIN)) \ 244 if (!capable(CAP_SYS_ADMIN)) \
243 return -EPERM; \ 245 return -EPERM; \
244 err = kstrtol(buf, 0, &value); \ 246 err = kstrtoull(buf, 0, &value); \
245 if (err) \ 247 if (err) \
246 return err; \ 248 return err; \
247 if (value) \ 249 if (value) \
248 state->disable = 1; \ 250 state_usage->_name = 1; \
249 else \ 251 else \
250 state->disable = 0; \ 252 state_usage->_name = 0; \
251 return size; \ 253 return size; \
252} 254}
253 255
@@ -273,8 +275,8 @@ define_show_state_ull_function(usage)
273define_show_state_ull_function(time) 275define_show_state_ull_function(time)
274define_show_state_str_function(name) 276define_show_state_str_function(name)
275define_show_state_str_function(desc) 277define_show_state_str_function(desc)
276define_show_state_function(disable) 278define_show_state_ull_function(disable)
277define_store_state_function(disable) 279define_store_state_ull_function(disable)
278 280
279define_one_state_ro(name, show_state_name); 281define_one_state_ro(name, show_state_name);
280define_one_state_ro(desc, show_state_desc); 282define_one_state_ro(desc, show_state_desc);
@@ -318,10 +320,11 @@ static ssize_t cpuidle_state_store(struct kobject *kobj,
318{ 320{
319 int ret = -EIO; 321 int ret = -EIO;
320 struct cpuidle_state *state = kobj_to_state(kobj); 322 struct cpuidle_state *state = kobj_to_state(kobj);
323 struct cpuidle_state_usage *state_usage = kobj_to_state_usage(kobj);
321 struct cpuidle_state_attr *cattr = attr_to_stateattr(attr); 324 struct cpuidle_state_attr *cattr = attr_to_stateattr(attr);
322 325
323 if (cattr->store) 326 if (cattr->store)
324 ret = cattr->store(state, buf, size); 327 ret = cattr->store(state, state_usage, buf, size);
325 328
326 return ret; 329 return ret;
327} 330}