Staging
v0.5.1
swh:1:snp:a902887e4be9191b7c6c4406aa06b31c1ce2c7cc
Raw File
Tip revision: 0d02ec6b3136c73c09e7859f0d0e4e2c4c07b49b authored by Linus Torvalds on 21 March 2021, 21:56:43 UTC
Linux 5.12-rc4
Tip revision: 0d02ec6
cpu.c
// SPDX-License-Identifier: GPL-2.0
#include <stdio.h>

#include "cpu.h"
#include "fs/fs.h"

int cpu__get_max_freq(unsigned long long *freq)
{
	char entry[PATH_MAX];
	int cpu;

	if (sysfs__read_int("devices/system/cpu/online", &cpu) < 0)
		return -1;

	snprintf(entry, sizeof(entry),
		 "devices/system/cpu/cpu%d/cpufreq/cpuinfo_max_freq", cpu);

	return sysfs__read_ull(entry, freq);
}
back to top