cpu.c 351 B

12345678910111213141516171819
  1. #include <stdio.h>
  2. #include "cpu.h"
  3. #include "fs/fs.h"
  4. int cpu__get_max_freq(unsigned long long *freq)
  5. {
  6. char entry[PATH_MAX];
  7. int cpu;
  8. if (sysfs__read_int("devices/system/cpu/online", &cpu) < 0)
  9. return -1;
  10. snprintf(entry, sizeof(entry),
  11. "devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq", cpu);
  12. return sysfs__read_ull(entry, freq);
  13. }