Staging
v0.5.1
swh:1:snp:a902887e4be9191b7c6c4406aa06b31c1ce2c7cc
Raw File
Tip revision: af42d3466bdc8f39806b26f593604fdc54140bcb authored by Linus Torvalds on 17 November 2019, 22:47:30 UTC
Linux 5.4-rc8
Tip revision: af42d34
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