Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 #include <stdio.h>
0003 
0004 #include "cpu.h"
0005 #include "fs/fs.h"
0006 
0007 int cpu__get_max_freq(unsigned long long *freq)
0008 {
0009     char entry[PATH_MAX];
0010     int cpu;
0011 
0012     if (sysfs__read_int("devices/system/cpu/online", &cpu) < 0)
0013         return -1;
0014 
0015     snprintf(entry, sizeof(entry),
0016          "devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq", cpu);
0017 
0018     return sysfs__read_ull(entry, freq);
0019 }