Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Arnaldo Carvalho de Melo | 09f6acf | 2015-09-10 12:20:14 -0300 | [diff] [blame] | 2 | #include <stdio.h> |
| 3 | |
| 4 | #include "cpu.h" |
| 5 | #include "fs/fs.h" |
| 6 | |
| 7 | int cpu__get_max_freq(unsigned long long *freq) |
| 8 | { |
| 9 | char entry[PATH_MAX]; |
| 10 | int cpu; |
| 11 | |
| 12 | if (sysfs__read_int("devices/system/cpu/online", &cpu) < 0) |
| 13 | return -1; |
| 14 | |
| 15 | snprintf(entry, sizeof(entry), |
| 16 | "devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq", cpu); |
| 17 | |
| 18 | return sysfs__read_ull(entry, freq); |
| 19 | } |