1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2020 Intel Corporation
9 #include "power_common.h"
11 #define POWER_SYSFILE_SCALING_DRIVER \
12 "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_driver"
15 cpufreq_check_scaling_driver(const char *driver_name)
17 unsigned int lcore_id = 0; /* always check core 0 */
18 char fullpath[PATH_MAX];
19 char readbuf[PATH_MAX];
24 * Check if scaling driver matches what we expect.
26 snprintf(fullpath, sizeof(fullpath), POWER_SYSFILE_SCALING_DRIVER,
28 f = fopen(fullpath, "r");
30 /* if there's no driver at all, bail out */
34 s = fgets(readbuf, sizeof(readbuf), f);
35 /* don't need it any more */
38 /* if we can't read it, consider unsupported */
42 /* does the driver name match? */
43 if (strncmp(readbuf, driver_name, sizeof(readbuf)) != 0)
47 * We might have a situation where the driver is supported, but we don't
48 * have permissions to do frequency scaling. This error should not be
49 * handled here, so consider the system to support scaling for now.