aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorThomas Renninger <trenn@suse.de>2013-06-28 09:34:29 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-07-04 19:52:19 -0400
commitf605181abd95a109031a23c67a824eb8e5dcfe67 (patch)
tree5601199a58e0c9f5d1cd1a3e4a07457ca7070247 /tools
parentf991fae5c6d42dfc5029150b05a78cf3f6c18cc9 (diff)
cpupower: Make idlestate usage unsigned
Use unsigned int as the data type for some variables related to CPU idle states which allows the code to be simplified slightly. [rjw: Changelog] Signed-off-by: Thomas Renninger <trenn@suse.de> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/power/cpupower/utils/cpuidle-info.c18
-rw-r--r--tools/power/cpupower/utils/helpers/sysfs.c2
-rw-r--r--tools/power/cpupower/utils/helpers/sysfs.h2
3 files changed, 6 insertions, 16 deletions
diff --git a/tools/power/cpupower/utils/cpuidle-info.c b/tools/power/cpupower/utils/cpuidle-info.c
index 8145af5f93a6..edd5dba3e249 100644
--- a/tools/power/cpupower/utils/cpuidle-info.c
+++ b/tools/power/cpupower/utils/cpuidle-info.c
@@ -22,7 +22,7 @@
22 22
23static void cpuidle_cpu_output(unsigned int cpu, int verbose) 23static void cpuidle_cpu_output(unsigned int cpu, int verbose)
24{ 24{
25 int idlestates, idlestate; 25 unsigned int idlestates, idlestate;
26 char *tmp; 26 char *tmp;
27 27
28 printf(_ ("Analyzing CPU %d:\n"), cpu); 28 printf(_ ("Analyzing CPU %d:\n"), cpu);
@@ -31,10 +31,8 @@ static void cpuidle_cpu_output(unsigned int cpu, int verbose)
31 if (idlestates == 0) { 31 if (idlestates == 0) {
32 printf(_("CPU %u: No idle states\n"), cpu); 32 printf(_("CPU %u: No idle states\n"), cpu);
33 return; 33 return;
34 } else if (idlestates <= 0) {
35 printf(_("CPU %u: Can't read idle state info\n"), cpu);
36 return;
37 } 34 }
35
38 printf(_("Number of idle states: %d\n"), idlestates); 36 printf(_("Number of idle states: %d\n"), idlestates);
39 printf(_("Available idle states:")); 37 printf(_("Available idle states:"));
40 for (idlestate = 0; idlestate < idlestates; idlestate++) { 38 for (idlestate = 0; idlestate < idlestates; idlestate++) {
@@ -98,21 +96,13 @@ static void cpuidle_general_output(void)
98static void proc_cpuidle_cpu_output(unsigned int cpu) 96static void proc_cpuidle_cpu_output(unsigned int cpu)
99{ 97{
100 long max_allowed_cstate = 2000000000; 98 long max_allowed_cstate = 2000000000;
101 int cstates, cstate; 99 unsigned int cstate, cstates;
102 100
103 cstates = sysfs_get_idlestate_count(cpu); 101 cstates = sysfs_get_idlestate_count(cpu);
104 if (cstates == 0) { 102 if (cstates == 0) {
105 /* 103 printf(_("CPU %u: No C-states info\n"), cpu);
106 * Go on and print same useless info as you'd see with
107 * cat /proc/acpi/processor/../power
108 * printf(_("CPU %u: No C-states available\n"), cpu);
109 * return;
110 */
111 } else if (cstates <= 0) {
112 printf(_("CPU %u: Can't read C-state info\n"), cpu);
113 return; 104 return;
114 } 105 }
115 /* printf("Cstates: %d\n", cstates); */
116 106
117 printf(_("active state: C0\n")); 107 printf(_("active state: C0\n"));
118 printf(_("max_cstate: C%u\n"), cstates-1); 108 printf(_("max_cstate: C%u\n"), cstates-1);
diff --git a/tools/power/cpupower/utils/helpers/sysfs.c b/tools/power/cpupower/utils/helpers/sysfs.c
index 38ab91629463..891f6710d026 100644
--- a/tools/power/cpupower/utils/helpers/sysfs.c
+++ b/tools/power/cpupower/utils/helpers/sysfs.c
@@ -238,7 +238,7 @@ char *sysfs_get_idlestate_desc(unsigned int cpu, unsigned int idlestate)
238 * Negativ in error case 238 * Negativ in error case
239 * Zero if cpuidle does not export any C-states 239 * Zero if cpuidle does not export any C-states
240 */ 240 */
241int sysfs_get_idlestate_count(unsigned int cpu) 241unsigned int sysfs_get_idlestate_count(unsigned int cpu)
242{ 242{
243 char file[SYSFS_PATH_MAX]; 243 char file[SYSFS_PATH_MAX];
244 struct stat statbuf; 244 struct stat statbuf;
diff --git a/tools/power/cpupower/utils/helpers/sysfs.h b/tools/power/cpupower/utils/helpers/sysfs.h
index 8cb797bbceb0..0401a97a4cab 100644
--- a/tools/power/cpupower/utils/helpers/sysfs.h
+++ b/tools/power/cpupower/utils/helpers/sysfs.h
@@ -19,7 +19,7 @@ extern char *sysfs_get_idlestate_name(unsigned int cpu,
19 unsigned int idlestate); 19 unsigned int idlestate);
20extern char *sysfs_get_idlestate_desc(unsigned int cpu, 20extern char *sysfs_get_idlestate_desc(unsigned int cpu,
21 unsigned int idlestate); 21 unsigned int idlestate);
22extern int sysfs_get_idlestate_count(unsigned int cpu); 22extern unsigned int sysfs_get_idlestate_count(unsigned int cpu);
23 23
24extern char *sysfs_get_cpuidle_governor(void); 24extern char *sysfs_get_cpuidle_governor(void);
25extern char *sysfs_get_cpuidle_driver(void); 25extern char *sysfs_get_cpuidle_driver(void);