1 // SPDX-License-Identifier: GPL-2.0-only
12 #include "cpupower_intern.h"
13 #include "acpi_cppc.h"
15 /* ACPI CPPC sysfs access ***********************************************/
17 static int acpi_cppc_read_file(unsigned int cpu, const char *fname,
18 char *buf, size_t buflen)
20 char path[SYSFS_PATH_MAX];
22 snprintf(path, sizeof(path), PATH_TO_CPU "cpu%u/acpi_cppc/%s",
24 return cpupower_read_sysfs(path, buf, buflen);
27 static const char * const acpi_cppc_value_files[] = {
28 [HIGHEST_PERF] = "highest_perf",
29 [LOWEST_PERF] = "lowest_perf",
30 [NOMINAL_PERF] = "nominal_perf",
31 [LOWEST_NONLINEAR_PERF] = "lowest_nonlinear_perf",
32 [LOWEST_FREQ] = "lowest_freq",
33 [NOMINAL_FREQ] = "nominal_freq",
34 [REFERENCE_PERF] = "reference_perf",
35 [WRAPAROUND_TIME] = "wraparound_time"
38 unsigned long acpi_cppc_get_data(unsigned int cpu, enum acpi_cppc_value which)
40 unsigned long long value;
42 char linebuf[MAX_LINE_LEN];
45 if (which >= MAX_CPPC_VALUE_FILES)
48 len = acpi_cppc_read_file(cpu, acpi_cppc_value_files[which],
49 linebuf, sizeof(linebuf));
53 value = strtoull(linebuf, &endp, 0);
55 if (endp == linebuf || errno == ERANGE)