Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Rafael J. Wysocki | 7d5905d | 2017-11-15 02:13:40 +0100 | [diff] [blame] | 2 | #include <linux/cpufreq.h> |
Alexey Dobriyan | 8591cf4 | 2008-10-04 23:40:23 +0400 | [diff] [blame] | 3 | #include <linux/fs.h> |
| 4 | #include <linux/init.h> |
| 5 | #include <linux/proc_fs.h> |
| 6 | #include <linux/seq_file.h> |
| 7 | |
Rafael J. Wysocki | 7d5905d | 2017-11-15 02:13:40 +0100 | [diff] [blame] | 8 | __weak void arch_freq_prepare_all(void) |
| 9 | { |
| 10 | } |
| 11 | |
Alexey Dobriyan | 8591cf4 | 2008-10-04 23:40:23 +0400 | [diff] [blame] | 12 | extern const struct seq_operations cpuinfo_op; |
| 13 | static int cpuinfo_open(struct inode *inode, struct file *file) |
| 14 | { |
Rafael J. Wysocki | 7d5905d | 2017-11-15 02:13:40 +0100 | [diff] [blame] | 15 | arch_freq_prepare_all(); |
Alexey Dobriyan | 8591cf4 | 2008-10-04 23:40:23 +0400 | [diff] [blame] | 16 | return seq_open(file, &cpuinfo_op); |
| 17 | } |
| 18 | |
Alexey Dobriyan | 97a3253 | 2020-02-03 17:37:17 -0800 | [diff] [blame] | 19 | static const struct proc_ops cpuinfo_proc_ops = { |
Alexey Dobriyan | d919b33 | 2020-04-06 20:09:01 -0700 | [diff] [blame] | 20 | .proc_flags = PROC_ENTRY_PERMANENT, |
Alexey Dobriyan | 97a3253 | 2020-02-03 17:37:17 -0800 | [diff] [blame] | 21 | .proc_open = cpuinfo_open, |
Christoph Hellwig | 70fce7d | 2020-11-04 09:27:35 +0100 | [diff] [blame] | 22 | .proc_read_iter = seq_read_iter, |
Alexey Dobriyan | 97a3253 | 2020-02-03 17:37:17 -0800 | [diff] [blame] | 23 | .proc_lseek = seq_lseek, |
| 24 | .proc_release = seq_release, |
Alexey Dobriyan | 8591cf4 | 2008-10-04 23:40:23 +0400 | [diff] [blame] | 25 | }; |
| 26 | |
| 27 | static int __init proc_cpuinfo_init(void) |
| 28 | { |
Alexey Dobriyan | 97a3253 | 2020-02-03 17:37:17 -0800 | [diff] [blame] | 29 | proc_create("cpuinfo", 0, NULL, &cpuinfo_proc_ops); |
Alexey Dobriyan | 8591cf4 | 2008-10-04 23:40:23 +0400 | [diff] [blame] | 30 | return 0; |
| 31 | } |
Paul Gortmaker | abaf378 | 2014-01-23 15:55:45 -0800 | [diff] [blame] | 32 | fs_initcall(proc_cpuinfo_init); |