diff mbox series

[2/7] cpupower: Add support for parsing 'enabled' or 'disabled' strings from table

Message ID 20241218191144.3440854-3-superm1@kernel.org (mailing list archive)
State Accepted
Delegated to: Shuah Khan
Headers show
Series cpupower improvements on AMD systems | expand

Commit Message

Mario Limonciello Dec. 18, 2024, 7:09 p.m. UTC
From: Mario Limonciello <mario.limonciello@amd.com>

When cpufreq_get_sysfs_value_from_table() is passed a table with
kernel strings that report 'enabled' or 'disabled' it always returns 0
because these can't cleanly convert to integers.

Explicitly look for enabled or disabled strings from the kernel to handle
this.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 tools/power/cpupower/lib/cpufreq.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/tools/power/cpupower/lib/cpufreq.c b/tools/power/cpupower/lib/cpufreq.c
index 1516d23c17c98..f27ee6d4b000c 100644
--- a/tools/power/cpupower/lib/cpufreq.c
+++ b/tools/power/cpupower/lib/cpufreq.c
@@ -102,6 +102,10 @@  unsigned long cpufreq_get_sysfs_value_from_table(unsigned int cpu,
 	if (len == 0)
 		return 0;
 
+	if (!strcmp(linebuf, "enabled\n"))
+		return 1;
+	if (!strcmp(linebuf, "disabled\n"))
+		return 0;
 	value = strtoul(linebuf, &endp, 0);
 
 	if (endp == linebuf || errno == ERANGE)