Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Thomas Renninger and committed by
Rafael J. Wysocki
f605181a f991fae5

+6 -16
+4 -14
tools/power/cpupower/utils/cpuidle-info.c
··· 22 22 23 23 static void cpuidle_cpu_output(unsigned int cpu, int verbose) 24 24 { 25 - int idlestates, idlestate; 25 + unsigned int idlestates, idlestate; 26 26 char *tmp; 27 27 28 28 printf(_ ("Analyzing CPU %d:\n"), cpu); ··· 31 31 if (idlestates == 0) { 32 32 printf(_("CPU %u: No idle states\n"), cpu); 33 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 36 printf(_("Number of idle states: %d\n"), idlestates); 39 37 printf(_("Available idle states:")); 40 38 for (idlestate = 0; idlestate < idlestates; idlestate++) { ··· 96 98 static void proc_cpuidle_cpu_output(unsigned int cpu) 97 99 { 98 100 long max_allowed_cstate = 2000000000; 99 - int cstates, cstate; 101 + unsigned int cstate, cstates; 100 102 101 103 cstates = sysfs_get_idlestate_count(cpu); 102 104 if (cstates == 0) { 103 - /* 104 - * Go on and print same useless info as you'd see with 105 - * cat /proc/acpi/processor/../power 106 - * printf(_("CPU %u: No C-states available\n"), cpu); 107 - * return; 108 - */ 109 - } else if (cstates <= 0) { 110 - printf(_("CPU %u: Can't read C-state info\n"), cpu); 105 + printf(_("CPU %u: No C-states info\n"), cpu); 111 106 return; 112 107 } 113 - /* printf("Cstates: %d\n", cstates); */ 114 108 115 109 printf(_("active state: C0\n")); 116 110 printf(_("max_cstate: C%u\n"), cstates-1);
+1 -1
tools/power/cpupower/utils/helpers/sysfs.c
··· 238 238 * Negativ in error case 239 239 * Zero if cpuidle does not export any C-states 240 240 */ 241 - int sysfs_get_idlestate_count(unsigned int cpu) 241 + unsigned int sysfs_get_idlestate_count(unsigned int cpu) 242 242 { 243 243 char file[SYSFS_PATH_MAX]; 244 244 struct stat statbuf;
+1 -1
tools/power/cpupower/utils/helpers/sysfs.h
··· 19 19 unsigned int idlestate); 20 20 extern char *sysfs_get_idlestate_desc(unsigned int cpu, 21 21 unsigned int idlestate); 22 - extern int sysfs_get_idlestate_count(unsigned int cpu); 22 + extern unsigned int sysfs_get_idlestate_count(unsigned int cpu); 23 23 24 24 extern char *sysfs_get_cpuidle_governor(void); 25 25 extern char *sysfs_get_cpuidle_driver(void);