forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/arch/powerpc/platforms/powernv/vas-debug.c
....@@ -1,10 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright 2016-17 IBM Corp.
3
- *
4
- * This program is free software; you can redistribute it and/or
5
- * modify it under the terms of the GNU General Public License
6
- * as published by the Free Software Foundation; either version
7
- * 2 of the License, or (at your option) any later version.
84 */
95
106 #define pr_fmt(fmt) "vas: " fmt
....@@ -30,7 +26,7 @@
3026 }
3127 }
3228
33
-static int info_dbg_show(struct seq_file *s, void *private)
29
+static int info_show(struct seq_file *s, void *private)
3430 {
3531 struct vas_window *window = s->private;
3632
....@@ -42,24 +38,14 @@
4238
4339 seq_printf(s, "Type: %s, %s\n", cop_to_str(window->cop),
4440 window->tx_win ? "Send" : "Receive");
45
- seq_printf(s, "Pid : %d\n", window->pid);
41
+ seq_printf(s, "Pid : %d\n", vas_window_pid(window));
4642
4743 unlock:
4844 mutex_unlock(&vas_mutex);
4945 return 0;
5046 }
5147
52
-static int info_dbg_open(struct inode *inode, struct file *file)
53
-{
54
- return single_open(file, info_dbg_show, inode->i_private);
55
-}
56
-
57
-static const struct file_operations info_fops = {
58
- .open = info_dbg_open,
59
- .read = seq_read,
60
- .llseek = seq_lseek,
61
- .release = single_release,
62
-};
48
+DEFINE_SHOW_ATTRIBUTE(info);
6349
6450 static inline void print_reg(struct seq_file *s, struct vas_window *win,
6551 char *name, u32 reg)
....@@ -67,7 +53,7 @@
6753 seq_printf(s, "0x%016llx %s\n", read_hvwc_reg(win, name, reg), name);
6854 }
6955
70
-static int hvwc_dbg_show(struct seq_file *s, void *private)
56
+static int hvwc_show(struct seq_file *s, void *private)
7157 {
7258 struct vas_window *window = s->private;
7359
....@@ -115,17 +101,7 @@
115101 return 0;
116102 }
117103
118
-static int hvwc_dbg_open(struct inode *inode, struct file *file)
119
-{
120
- return single_open(file, hvwc_dbg_show, inode->i_private);
121
-}
122
-
123
-static const struct file_operations hvwc_fops = {
124
- .open = hvwc_dbg_open,
125
- .read = seq_read,
126
- .llseek = seq_lseek,
127
- .release = single_release,
128
-};
104
+DEFINE_SHOW_ATTRIBUTE(hvwc);
129105
130106 void vas_window_free_dbgdir(struct vas_window *window)
131107 {
....@@ -139,7 +115,7 @@
139115
140116 void vas_window_init_dbgdir(struct vas_window *window)
141117 {
142
- struct dentry *f, *d;
118
+ struct dentry *d;
143119
144120 if (!window->vinst->dbgdir)
145121 return;
....@@ -151,28 +127,10 @@
151127 snprintf(window->dbgname, 16, "w%d", window->winid);
152128
153129 d = debugfs_create_dir(window->dbgname, window->vinst->dbgdir);
154
- if (IS_ERR(d))
155
- goto free_name;
156
-
157130 window->dbgdir = d;
158131
159
- f = debugfs_create_file("info", 0444, d, window, &info_fops);
160
- if (IS_ERR(f))
161
- goto remove_dir;
162
-
163
- f = debugfs_create_file("hvwc", 0444, d, window, &hvwc_fops);
164
- if (IS_ERR(f))
165
- goto remove_dir;
166
-
167
- return;
168
-
169
-remove_dir:
170
- debugfs_remove_recursive(window->dbgdir);
171
- window->dbgdir = NULL;
172
-
173
-free_name:
174
- kfree(window->dbgname);
175
- window->dbgname = NULL;
132
+ debugfs_create_file("info", 0444, d, window, &info_fops);
133
+ debugfs_create_file("hvwc", 0444, d, window, &hvwc_fops);
176134 }
177135
178136 void vas_instance_init_dbgdir(struct vas_instance *vinst)
....@@ -180,8 +138,6 @@
180138 struct dentry *d;
181139
182140 vas_init_dbgdir();
183
- if (!vas_debugfs)
184
- return;
185141
186142 vinst->dbgname = kzalloc(16, GFP_KERNEL);
187143 if (!vinst->dbgname)
....@@ -190,16 +146,7 @@
190146 snprintf(vinst->dbgname, 16, "v%d", vinst->vas_id);
191147
192148 d = debugfs_create_dir(vinst->dbgname, vas_debugfs);
193
- if (IS_ERR(d))
194
- goto free_name;
195
-
196149 vinst->dbgdir = d;
197
- return;
198
-
199
-free_name:
200
- kfree(vinst->dbgname);
201
- vinst->dbgname = NULL;
202
- vinst->dbgdir = NULL;
203150 }
204151
205152 /*
....@@ -215,6 +162,4 @@
215162
216163 first_time = false;
217164 vas_debugfs = debugfs_create_dir("vas", NULL);
218
- if (IS_ERR(vas_debugfs))
219
- vas_debugfs = NULL;
220165 }