| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2006 Mike Kravetz IBM Corporation |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Hypervisor Call Instrumentation |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 8 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | | - * (at your option) any later version. |
|---|
| 10 | | - * |
|---|
| 11 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | | - * GNU General Public License for more details. |
|---|
| 15 | | - * |
|---|
| 16 | | - * You should have received a copy of the GNU General Public License |
|---|
| 17 | | - * along with this program; if not, write to the Free Software |
|---|
| 18 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 19 | 6 | */ |
|---|
| 20 | 7 | |
|---|
| 21 | 8 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 83 | 70 | return 0; |
|---|
| 84 | 71 | } |
|---|
| 85 | 72 | |
|---|
| 86 | | -static const struct seq_operations hcall_inst_seq_ops = { |
|---|
| 73 | +static const struct seq_operations hcall_inst_sops = { |
|---|
| 87 | 74 | .start = hc_start, |
|---|
| 88 | 75 | .next = hc_next, |
|---|
| 89 | 76 | .stop = hc_stop, |
|---|
| 90 | 77 | .show = hc_show |
|---|
| 91 | 78 | }; |
|---|
| 92 | 79 | |
|---|
| 93 | | -static int hcall_inst_seq_open(struct inode *inode, struct file *file) |
|---|
| 94 | | -{ |
|---|
| 95 | | - int rc; |
|---|
| 96 | | - struct seq_file *seq; |
|---|
| 97 | | - |
|---|
| 98 | | - rc = seq_open(file, &hcall_inst_seq_ops); |
|---|
| 99 | | - seq = file->private_data; |
|---|
| 100 | | - seq->private = file_inode(file)->i_private; |
|---|
| 101 | | - |
|---|
| 102 | | - return rc; |
|---|
| 103 | | -} |
|---|
| 104 | | - |
|---|
| 105 | | -static const struct file_operations hcall_inst_seq_fops = { |
|---|
| 106 | | - .open = hcall_inst_seq_open, |
|---|
| 107 | | - .read = seq_read, |
|---|
| 108 | | - .llseek = seq_lseek, |
|---|
| 109 | | - .release = seq_release, |
|---|
| 110 | | -}; |
|---|
| 80 | +DEFINE_SEQ_ATTRIBUTE(hcall_inst); |
|---|
| 111 | 81 | |
|---|
| 112 | 82 | #define HCALL_ROOT_DIR "hcall_inst" |
|---|
| 113 | 83 | #define CPU_NAME_BUF_SIZE 32 |
|---|
| .. | .. |
|---|
| 142 | 112 | static int __init hcall_inst_init(void) |
|---|
| 143 | 113 | { |
|---|
| 144 | 114 | struct dentry *hcall_root; |
|---|
| 145 | | - struct dentry *hcall_file; |
|---|
| 146 | 115 | char cpu_name_buf[CPU_NAME_BUF_SIZE]; |
|---|
| 147 | 116 | int cpu; |
|---|
| 148 | 117 | |
|---|
| .. | .. |
|---|
| 158 | 127 | } |
|---|
| 159 | 128 | |
|---|
| 160 | 129 | hcall_root = debugfs_create_dir(HCALL_ROOT_DIR, NULL); |
|---|
| 161 | | - if (!hcall_root) |
|---|
| 162 | | - return -ENOMEM; |
|---|
| 163 | 130 | |
|---|
| 164 | 131 | for_each_possible_cpu(cpu) { |
|---|
| 165 | 132 | snprintf(cpu_name_buf, CPU_NAME_BUF_SIZE, "cpu%d", cpu); |
|---|
| 166 | | - hcall_file = debugfs_create_file(cpu_name_buf, 0444, |
|---|
| 167 | | - hcall_root, |
|---|
| 168 | | - per_cpu(hcall_stats, cpu), |
|---|
| 169 | | - &hcall_inst_seq_fops); |
|---|
| 170 | | - if (!hcall_file) |
|---|
| 171 | | - return -ENOMEM; |
|---|
| 133 | + debugfs_create_file(cpu_name_buf, 0444, hcall_root, |
|---|
| 134 | + per_cpu(hcall_stats, cpu), |
|---|
| 135 | + &hcall_inst_fops); |
|---|
| 172 | 136 | } |
|---|
| 173 | 137 | |
|---|
| 174 | 138 | return 0; |
|---|