Skip to content

Commit f4a5d17

Browse files
watologo1rafaeljw
authored andcommitted
tools: cpupower: fix wrong err msg not supported vs not available
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 <trenn@suse.de> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 5094d27 commit f4a5d17

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • tools/power/cpupower/utils/helpers

‎tools/power/cpupower/utils/helpers/sysfs.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ static char *sysfs_idlestate_get_one_string(unsigned int cpu,
278278
int sysfs_is_idlestate_disabled(unsigned int cpu,
279279
unsigned int idlestate)
280280
{
281-
if (sysfs_get_idlestate_count(cpu) < idlestate)
281+
if (sysfs_get_idlestate_count(cpu) <= idlestate)
282282
return -1;
283283

284284
if (!sysfs_idlestate_file_exists(cpu, idlestate,
@@ -303,7 +303,7 @@ int sysfs_idlestate_disable(unsigned int cpu,
303303
char value[SYSFS_PATH_MAX];
304304
int bytes_written;
305305

306-
if (sysfs_get_idlestate_count(cpu) < idlestate)
306+
if (sysfs_get_idlestate_count(cpu) <= idlestate)
307307
return -1;
308308

309309
if (!sysfs_idlestate_file_exists(cpu, idlestate,

0 commit comments

Comments
 (0)