^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #include <stdio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include "cpu.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include "fs/fs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) int cpu__get_max_freq(unsigned long long *freq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) char entry[PATH_MAX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) int cpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) if (sysfs__read_int("devices/system/cpu/online", &cpu) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) snprintf(entry, sizeof(entry),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) "devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq", cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) return sysfs__read_ull(entry, freq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) }