1*b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0 209f6acf2SArnaldo Carvalho de Melo #include <stdio.h> 309f6acf2SArnaldo Carvalho de Melo 409f6acf2SArnaldo Carvalho de Melo #include "cpu.h" 509f6acf2SArnaldo Carvalho de Melo #include "fs/fs.h" 609f6acf2SArnaldo Carvalho de Melo cpu__get_max_freq(unsigned long long * freq)709f6acf2SArnaldo Carvalho de Meloint cpu__get_max_freq(unsigned long long *freq) 809f6acf2SArnaldo Carvalho de Melo { 909f6acf2SArnaldo Carvalho de Melo char entry[PATH_MAX]; 1009f6acf2SArnaldo Carvalho de Melo int cpu; 1109f6acf2SArnaldo Carvalho de Melo 1209f6acf2SArnaldo Carvalho de Melo if (sysfs__read_int("devices/system/cpu/online", &cpu) < 0) 1309f6acf2SArnaldo Carvalho de Melo return -1; 1409f6acf2SArnaldo Carvalho de Melo 1509f6acf2SArnaldo Carvalho de Melo snprintf(entry, sizeof(entry), 1609f6acf2SArnaldo Carvalho de Melo "devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq", cpu); 1709f6acf2SArnaldo Carvalho de Melo 1809f6acf2SArnaldo Carvalho de Melo return sysfs__read_ull(entry, freq); 1909f6acf2SArnaldo Carvalho de Melo } 20