blob: 419760fd77bdd82b1fa1d1565bbcc8d13ae25967 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Rafael J. Wysocki7d5905d2017-11-15 02:13:40 +01002#include <linux/cpufreq.h>
Alexey Dobriyan8591cf42008-10-04 23:40:23 +04003#include <linux/fs.h>
4#include <linux/init.h>
5#include <linux/proc_fs.h>
6#include <linux/seq_file.h>
7
Rafael J. Wysocki7d5905d2017-11-15 02:13:40 +01008__weak void arch_freq_prepare_all(void)
9{
10}
11
Alexey Dobriyan8591cf42008-10-04 23:40:23 +040012extern const struct seq_operations cpuinfo_op;
13static int cpuinfo_open(struct inode *inode, struct file *file)
14{
Rafael J. Wysocki7d5905d2017-11-15 02:13:40 +010015 arch_freq_prepare_all();
Alexey Dobriyan8591cf42008-10-04 23:40:23 +040016 return seq_open(file, &cpuinfo_op);
17}
18
Alexey Dobriyan97a32532020-02-03 17:37:17 -080019static const struct proc_ops cpuinfo_proc_ops = {
Alexey Dobriyand919b332020-04-06 20:09:01 -070020 .proc_flags = PROC_ENTRY_PERMANENT,
Alexey Dobriyan97a32532020-02-03 17:37:17 -080021 .proc_open = cpuinfo_open,
Christoph Hellwig70fce7d2020-11-04 09:27:35 +010022 .proc_read_iter = seq_read_iter,
Alexey Dobriyan97a32532020-02-03 17:37:17 -080023 .proc_lseek = seq_lseek,
24 .proc_release = seq_release,
Alexey Dobriyan8591cf42008-10-04 23:40:23 +040025};
26
27static int __init proc_cpuinfo_init(void)
28{
Alexey Dobriyan97a32532020-02-03 17:37:17 -080029 proc_create("cpuinfo", 0, NULL, &cpuinfo_proc_ops);
Alexey Dobriyan8591cf42008-10-04 23:40:23 +040030 return 0;
31}
Paul Gortmakerabaf3782014-01-23 15:55:45 -080032fs_initcall(proc_cpuinfo_init);