.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * 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. |
---|
8 | 4 | */ |
---|
9 | 5 | |
---|
10 | 6 | #define pr_fmt(fmt) "vas: " fmt |
---|
.. | .. |
---|
30 | 26 | } |
---|
31 | 27 | } |
---|
32 | 28 | |
---|
33 | | -static int info_dbg_show(struct seq_file *s, void *private) |
---|
| 29 | +static int info_show(struct seq_file *s, void *private) |
---|
34 | 30 | { |
---|
35 | 31 | struct vas_window *window = s->private; |
---|
36 | 32 | |
---|
.. | .. |
---|
42 | 38 | |
---|
43 | 39 | seq_printf(s, "Type: %s, %s\n", cop_to_str(window->cop), |
---|
44 | 40 | 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)); |
---|
46 | 42 | |
---|
47 | 43 | unlock: |
---|
48 | 44 | mutex_unlock(&vas_mutex); |
---|
49 | 45 | return 0; |
---|
50 | 46 | } |
---|
51 | 47 | |
---|
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); |
---|
63 | 49 | |
---|
64 | 50 | static inline void print_reg(struct seq_file *s, struct vas_window *win, |
---|
65 | 51 | char *name, u32 reg) |
---|
.. | .. |
---|
67 | 53 | seq_printf(s, "0x%016llx %s\n", read_hvwc_reg(win, name, reg), name); |
---|
68 | 54 | } |
---|
69 | 55 | |
---|
70 | | -static int hvwc_dbg_show(struct seq_file *s, void *private) |
---|
| 56 | +static int hvwc_show(struct seq_file *s, void *private) |
---|
71 | 57 | { |
---|
72 | 58 | struct vas_window *window = s->private; |
---|
73 | 59 | |
---|
.. | .. |
---|
115 | 101 | return 0; |
---|
116 | 102 | } |
---|
117 | 103 | |
---|
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); |
---|
129 | 105 | |
---|
130 | 106 | void vas_window_free_dbgdir(struct vas_window *window) |
---|
131 | 107 | { |
---|
.. | .. |
---|
139 | 115 | |
---|
140 | 116 | void vas_window_init_dbgdir(struct vas_window *window) |
---|
141 | 117 | { |
---|
142 | | - struct dentry *f, *d; |
---|
| 118 | + struct dentry *d; |
---|
143 | 119 | |
---|
144 | 120 | if (!window->vinst->dbgdir) |
---|
145 | 121 | return; |
---|
.. | .. |
---|
151 | 127 | snprintf(window->dbgname, 16, "w%d", window->winid); |
---|
152 | 128 | |
---|
153 | 129 | d = debugfs_create_dir(window->dbgname, window->vinst->dbgdir); |
---|
154 | | - if (IS_ERR(d)) |
---|
155 | | - goto free_name; |
---|
156 | | - |
---|
157 | 130 | window->dbgdir = d; |
---|
158 | 131 | |
---|
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); |
---|
176 | 134 | } |
---|
177 | 135 | |
---|
178 | 136 | void vas_instance_init_dbgdir(struct vas_instance *vinst) |
---|
.. | .. |
---|
180 | 138 | struct dentry *d; |
---|
181 | 139 | |
---|
182 | 140 | vas_init_dbgdir(); |
---|
183 | | - if (!vas_debugfs) |
---|
184 | | - return; |
---|
185 | 141 | |
---|
186 | 142 | vinst->dbgname = kzalloc(16, GFP_KERNEL); |
---|
187 | 143 | if (!vinst->dbgname) |
---|
.. | .. |
---|
190 | 146 | snprintf(vinst->dbgname, 16, "v%d", vinst->vas_id); |
---|
191 | 147 | |
---|
192 | 148 | d = debugfs_create_dir(vinst->dbgname, vas_debugfs); |
---|
193 | | - if (IS_ERR(d)) |
---|
194 | | - goto free_name; |
---|
195 | | - |
---|
196 | 149 | vinst->dbgdir = d; |
---|
197 | | - return; |
---|
198 | | - |
---|
199 | | -free_name: |
---|
200 | | - kfree(vinst->dbgname); |
---|
201 | | - vinst->dbgname = NULL; |
---|
202 | | - vinst->dbgdir = NULL; |
---|
203 | 150 | } |
---|
204 | 151 | |
---|
205 | 152 | /* |
---|
.. | .. |
---|
215 | 162 | |
---|
216 | 163 | first_time = false; |
---|
217 | 164 | vas_debugfs = debugfs_create_dir("vas", NULL); |
---|
218 | | - if (IS_ERR(vas_debugfs)) |
---|
219 | | - vas_debugfs = NULL; |
---|
220 | 165 | } |
---|