Commit d3f5d2a1 authored by Janakarajan Natarajan's avatar Janakarajan Natarajan Committed by Shuah Khan

cpupower: Move needs_root variable into a sub-struct

Move the needs_root variable into a sub-struct. This is in preparation
for adding a new flag for cpuidle_monitor.

Update all uses of the needs_root variable to reflect this change.
Signed-off-by: default avatarJanakarajan Natarajan <Janakarajan.Natarajan@amd.com>
Acked-by: default avatarThomas Renninger <trenn@suse.de>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent d80a4ac2
...@@ -328,7 +328,7 @@ struct cpuidle_monitor amd_fam14h_monitor = { ...@@ -328,7 +328,7 @@ struct cpuidle_monitor amd_fam14h_monitor = {
.stop = amd_fam14h_stop, .stop = amd_fam14h_stop,
.do_register = amd_fam14h_register, .do_register = amd_fam14h_register,
.unregister = amd_fam14h_unregister, .unregister = amd_fam14h_unregister,
.needs_root = 1, .flags.needs_root = 1,
.overflow_s = OVERFLOW_MS / 1000, .overflow_s = OVERFLOW_MS / 1000,
}; };
#endif /* #if defined(__i386__) || defined(__x86_64__) */ #endif /* #if defined(__i386__) || defined(__x86_64__) */
...@@ -207,6 +207,6 @@ struct cpuidle_monitor cpuidle_sysfs_monitor = { ...@@ -207,6 +207,6 @@ struct cpuidle_monitor cpuidle_sysfs_monitor = {
.stop = cpuidle_stop, .stop = cpuidle_stop,
.do_register = cpuidle_register, .do_register = cpuidle_register,
.unregister = cpuidle_unregister, .unregister = cpuidle_unregister,
.needs_root = 0, .flags.needs_root = 0,
.overflow_s = UINT_MAX, .overflow_s = UINT_MAX,
}; };
...@@ -408,7 +408,7 @@ int cmd_monitor(int argc, char **argv) ...@@ -408,7 +408,7 @@ int cmd_monitor(int argc, char **argv)
dprint("Try to register: %s\n", all_monitors[num]->name); dprint("Try to register: %s\n", all_monitors[num]->name);
test_mon = all_monitors[num]->do_register(); test_mon = all_monitors[num]->do_register();
if (test_mon) { if (test_mon) {
if (test_mon->needs_root && !run_as_root) { if (test_mon->flags.needs_root && !run_as_root) {
fprintf(stderr, _("Available monitor %s needs " fprintf(stderr, _("Available monitor %s needs "
"root access\n"), test_mon->name); "root access\n"), test_mon->name);
continue; continue;
......
...@@ -60,7 +60,9 @@ struct cpuidle_monitor { ...@@ -60,7 +60,9 @@ struct cpuidle_monitor {
struct cpuidle_monitor* (*do_register) (void); struct cpuidle_monitor* (*do_register) (void);
void (*unregister)(void); void (*unregister)(void);
unsigned int overflow_s; unsigned int overflow_s;
int needs_root; struct {
unsigned int needs_root:1;
} flags;
}; };
extern long long timespec_diff_us(struct timespec start, struct timespec end); extern long long timespec_diff_us(struct timespec start, struct timespec end);
......
...@@ -187,7 +187,7 @@ struct cpuidle_monitor intel_hsw_ext_monitor = { ...@@ -187,7 +187,7 @@ struct cpuidle_monitor intel_hsw_ext_monitor = {
.stop = hsw_ext_stop, .stop = hsw_ext_stop,
.do_register = hsw_ext_register, .do_register = hsw_ext_register,
.unregister = hsw_ext_unregister, .unregister = hsw_ext_unregister,
.needs_root = 1, .flags.needs_root = 1,
.overflow_s = 922000000 /* 922337203 seconds TSC overflow .overflow_s = 922000000 /* 922337203 seconds TSC overflow
at 20GHz */ at 20GHz */
}; };
......
...@@ -333,7 +333,7 @@ struct cpuidle_monitor mperf_monitor = { ...@@ -333,7 +333,7 @@ struct cpuidle_monitor mperf_monitor = {
.stop = mperf_stop, .stop = mperf_stop,
.do_register = mperf_register, .do_register = mperf_register,
.unregister = mperf_unregister, .unregister = mperf_unregister,
.needs_root = 1, .flags.needs_root = 1,
.overflow_s = 922000000 /* 922337203 seconds TSC overflow .overflow_s = 922000000 /* 922337203 seconds TSC overflow
at 20GHz */ at 20GHz */
}; };
......
...@@ -208,7 +208,7 @@ struct cpuidle_monitor intel_nhm_monitor = { ...@@ -208,7 +208,7 @@ struct cpuidle_monitor intel_nhm_monitor = {
.stop = nhm_stop, .stop = nhm_stop,
.do_register = intel_nhm_register, .do_register = intel_nhm_register,
.unregister = intel_nhm_unregister, .unregister = intel_nhm_unregister,
.needs_root = 1, .flags.needs_root = 1,
.overflow_s = 922000000 /* 922337203 seconds TSC overflow .overflow_s = 922000000 /* 922337203 seconds TSC overflow
at 20GHz */ at 20GHz */
}; };
......
...@@ -192,7 +192,7 @@ struct cpuidle_monitor intel_snb_monitor = { ...@@ -192,7 +192,7 @@ struct cpuidle_monitor intel_snb_monitor = {
.stop = snb_stop, .stop = snb_stop,
.do_register = snb_register, .do_register = snb_register,
.unregister = snb_unregister, .unregister = snb_unregister,
.needs_root = 1, .flags.needs_root = 1,
.overflow_s = 922000000 /* 922337203 seconds TSC overflow .overflow_s = 922000000 /* 922337203 seconds TSC overflow
at 20GHz */ at 20GHz */
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment