Skip to content

Commit

Permalink
tools: cpupower: fix wrong err msg not supported vs not available
Browse files Browse the repository at this point in the history
idlestates in sysfs are counted from 0.

This fixes a wrong error message.
Current behavior on a machine with 4 sleep states is:

cpupower idle-set -e 4
Idlestate 4 enabled on CPU 0

-----Wrong---------------------
cpupower idle-set -e 5
Idlestate enabling not supported by kernel
-----Must and now will be -----
cpupower idle-set -e 5
Idlestate 6 not available on CPU 0
-------------------------------

cpupower idle-set -e 6
Idlestate 6 not available on CPU 0

Signed-off-by: Thomas Renninger <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
  • Loading branch information
watologo1 authored and rafaeljw committed Nov 25, 2013
1 parent 5094d27 commit f4a5d17
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/power/cpupower/utils/helpers/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ static char *sysfs_idlestate_get_one_string(unsigned int cpu,
int sysfs_is_idlestate_disabled(unsigned int cpu,
unsigned int idlestate)
{
if (sysfs_get_idlestate_count(cpu) < idlestate)
if (sysfs_get_idlestate_count(cpu) <= idlestate)
return -1;

if (!sysfs_idlestate_file_exists(cpu, idlestate,
Expand All @@ -303,7 +303,7 @@ int sysfs_idlestate_disable(unsigned int cpu,
char value[SYSFS_PATH_MAX];
int bytes_written;

if (sysfs_get_idlestate_count(cpu) < idlestate)
if (sysfs_get_idlestate_count(cpu) <= idlestate)
return -1;

if (!sysfs_idlestate_file_exists(cpu, idlestate,
Expand Down

0 comments on commit f4a5d17

Please sign in to comment.