.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Intel Wireless WiMAX Connection 2400m |
---|
3 | 4 | * Debugfs interfaces to manipulate driver and device information |
---|
4 | 5 | * |
---|
5 | | - * |
---|
6 | 6 | * Copyright (C) 2007 Intel Corporation <linux-wimax@intel.com> |
---|
7 | 7 | * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> |
---|
8 | | - * |
---|
9 | | - * This program is free software; you can redistribute it and/or |
---|
10 | | - * modify it under the terms of the GNU General Public License version |
---|
11 | | - * 2 as published by the Free Software Foundation. |
---|
12 | | - * |
---|
13 | | - * This program is distributed in the hope that it will be useful, |
---|
14 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | | - * GNU General Public License for more details. |
---|
17 | | - * |
---|
18 | | - * You should have received a copy of the GNU General Public License |
---|
19 | | - * along with this program; if not, write to the Free Software |
---|
20 | | - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
---|
21 | | - * 02110-1301, USA. |
---|
22 | 8 | */ |
---|
23 | 9 | |
---|
24 | 10 | #include <linux/debugfs.h> |
---|
.. | .. |
---|
40 | 26 | *val = netif_queue_stopped(i2400m->wimax_dev.net_dev); |
---|
41 | 27 | return 0; |
---|
42 | 28 | } |
---|
43 | | -DEFINE_SIMPLE_ATTRIBUTE(fops_netdev_queue_stopped, |
---|
| 29 | +DEFINE_DEBUGFS_ATTRIBUTE(fops_netdev_queue_stopped, |
---|
44 | 30 | debugfs_netdev_queue_stopped_get, |
---|
45 | 31 | NULL, "%llu\n"); |
---|
46 | | - |
---|
47 | | - |
---|
48 | | -static |
---|
49 | | -struct dentry *debugfs_create_netdev_queue_stopped( |
---|
50 | | - const char *name, struct dentry *parent, struct i2400m *i2400m) |
---|
51 | | -{ |
---|
52 | | - return debugfs_create_file(name, 0400, parent, i2400m, |
---|
53 | | - &fops_netdev_queue_stopped); |
---|
54 | | -} |
---|
55 | 32 | |
---|
56 | 33 | /* |
---|
57 | 34 | * We don't allow partial reads of this file, as then the reader would |
---|
.. | .. |
---|
177 | 154 | result = 0; |
---|
178 | 155 | return result; |
---|
179 | 156 | } |
---|
180 | | -DEFINE_SIMPLE_ATTRIBUTE(fops_i2400m_suspend, |
---|
| 157 | +DEFINE_DEBUGFS_ATTRIBUTE(fops_i2400m_suspend, |
---|
181 | 158 | NULL, debugfs_i2400m_suspend_set, |
---|
182 | 159 | "%llu\n"); |
---|
183 | | - |
---|
184 | | -static |
---|
185 | | -struct dentry *debugfs_create_i2400m_suspend( |
---|
186 | | - const char *name, struct dentry *parent, struct i2400m *i2400m) |
---|
187 | | -{ |
---|
188 | | - return debugfs_create_file(name, 0200, parent, i2400m, |
---|
189 | | - &fops_i2400m_suspend); |
---|
190 | | -} |
---|
191 | | - |
---|
192 | 160 | |
---|
193 | 161 | /* |
---|
194 | 162 | * Reset the device |
---|
.. | .. |
---|
215 | 183 | } |
---|
216 | 184 | return result; |
---|
217 | 185 | } |
---|
218 | | -DEFINE_SIMPLE_ATTRIBUTE(fops_i2400m_reset, |
---|
| 186 | +DEFINE_DEBUGFS_ATTRIBUTE(fops_i2400m_reset, |
---|
219 | 187 | NULL, debugfs_i2400m_reset_set, |
---|
220 | 188 | "%llu\n"); |
---|
221 | 189 | |
---|
222 | | -static |
---|
223 | | -struct dentry *debugfs_create_i2400m_reset( |
---|
224 | | - const char *name, struct dentry *parent, struct i2400m *i2400m) |
---|
| 190 | +void i2400m_debugfs_add(struct i2400m *i2400m) |
---|
225 | 191 | { |
---|
226 | | - return debugfs_create_file(name, 0200, parent, i2400m, |
---|
227 | | - &fops_i2400m_reset); |
---|
228 | | -} |
---|
229 | | - |
---|
230 | | - |
---|
231 | | -#define __debugfs_register(prefix, name, parent) \ |
---|
232 | | -do { \ |
---|
233 | | - result = d_level_register_debugfs(prefix, name, parent); \ |
---|
234 | | - if (result < 0) \ |
---|
235 | | - goto error; \ |
---|
236 | | -} while (0) |
---|
237 | | - |
---|
238 | | - |
---|
239 | | -int i2400m_debugfs_add(struct i2400m *i2400m) |
---|
240 | | -{ |
---|
241 | | - int result; |
---|
242 | | - struct device *dev = i2400m_dev(i2400m); |
---|
243 | 192 | struct dentry *dentry = i2400m->wimax_dev.debugfs_dentry; |
---|
244 | | - struct dentry *fd; |
---|
245 | 193 | |
---|
246 | 194 | dentry = debugfs_create_dir("i2400m", dentry); |
---|
247 | | - result = PTR_ERR(dentry); |
---|
248 | | - if (IS_ERR(dentry)) { |
---|
249 | | - if (result == -ENODEV) |
---|
250 | | - result = 0; /* No debugfs support */ |
---|
251 | | - goto error; |
---|
252 | | - } |
---|
253 | 195 | i2400m->debugfs_dentry = dentry; |
---|
254 | | - __debugfs_register("dl_", control, dentry); |
---|
255 | | - __debugfs_register("dl_", driver, dentry); |
---|
256 | | - __debugfs_register("dl_", debugfs, dentry); |
---|
257 | | - __debugfs_register("dl_", fw, dentry); |
---|
258 | | - __debugfs_register("dl_", netdev, dentry); |
---|
259 | | - __debugfs_register("dl_", rfkill, dentry); |
---|
260 | | - __debugfs_register("dl_", rx, dentry); |
---|
261 | | - __debugfs_register("dl_", tx, dentry); |
---|
262 | 196 | |
---|
263 | | - fd = debugfs_create_size_t("tx_in", 0400, dentry, |
---|
264 | | - &i2400m->tx_in); |
---|
265 | | - result = PTR_ERR(fd); |
---|
266 | | - if (IS_ERR(fd) && result != -ENODEV) { |
---|
267 | | - dev_err(dev, "Can't create debugfs entry " |
---|
268 | | - "tx_in: %d\n", result); |
---|
269 | | - goto error; |
---|
270 | | - } |
---|
| 197 | + d_level_register_debugfs("dl_", control, dentry); |
---|
| 198 | + d_level_register_debugfs("dl_", driver, dentry); |
---|
| 199 | + d_level_register_debugfs("dl_", debugfs, dentry); |
---|
| 200 | + d_level_register_debugfs("dl_", fw, dentry); |
---|
| 201 | + d_level_register_debugfs("dl_", netdev, dentry); |
---|
| 202 | + d_level_register_debugfs("dl_", rfkill, dentry); |
---|
| 203 | + d_level_register_debugfs("dl_", rx, dentry); |
---|
| 204 | + d_level_register_debugfs("dl_", tx, dentry); |
---|
271 | 205 | |
---|
272 | | - fd = debugfs_create_size_t("tx_out", 0400, dentry, |
---|
273 | | - &i2400m->tx_out); |
---|
274 | | - result = PTR_ERR(fd); |
---|
275 | | - if (IS_ERR(fd) && result != -ENODEV) { |
---|
276 | | - dev_err(dev, "Can't create debugfs entry " |
---|
277 | | - "tx_out: %d\n", result); |
---|
278 | | - goto error; |
---|
279 | | - } |
---|
280 | | - |
---|
281 | | - fd = debugfs_create_u32("state", 0600, dentry, |
---|
282 | | - &i2400m->state); |
---|
283 | | - result = PTR_ERR(fd); |
---|
284 | | - if (IS_ERR(fd) && result != -ENODEV) { |
---|
285 | | - dev_err(dev, "Can't create debugfs entry " |
---|
286 | | - "state: %d\n", result); |
---|
287 | | - goto error; |
---|
288 | | - } |
---|
| 206 | + debugfs_create_size_t("tx_in", 0400, dentry, &i2400m->tx_in); |
---|
| 207 | + debugfs_create_size_t("tx_out", 0400, dentry, &i2400m->tx_out); |
---|
| 208 | + debugfs_create_u32("state", 0600, dentry, &i2400m->state); |
---|
289 | 209 | |
---|
290 | 210 | /* |
---|
291 | 211 | * Trace received messages from user space |
---|
.. | .. |
---|
309 | 229 | * It is not really very atomic, but it is also not too |
---|
310 | 230 | * critical. |
---|
311 | 231 | */ |
---|
312 | | - fd = debugfs_create_u8("trace_msg_from_user", 0600, dentry, |
---|
313 | | - &i2400m->trace_msg_from_user); |
---|
314 | | - result = PTR_ERR(fd); |
---|
315 | | - if (IS_ERR(fd) && result != -ENODEV) { |
---|
316 | | - dev_err(dev, "Can't create debugfs entry " |
---|
317 | | - "trace_msg_from_user: %d\n", result); |
---|
318 | | - goto error; |
---|
319 | | - } |
---|
| 232 | + debugfs_create_u8("trace_msg_from_user", 0600, dentry, |
---|
| 233 | + &i2400m->trace_msg_from_user); |
---|
320 | 234 | |
---|
321 | | - fd = debugfs_create_netdev_queue_stopped("netdev_queue_stopped", |
---|
322 | | - dentry, i2400m); |
---|
323 | | - result = PTR_ERR(fd); |
---|
324 | | - if (IS_ERR(fd) && result != -ENODEV) { |
---|
325 | | - dev_err(dev, "Can't create debugfs entry " |
---|
326 | | - "netdev_queue_stopped: %d\n", result); |
---|
327 | | - goto error; |
---|
328 | | - } |
---|
| 235 | + debugfs_create_file("netdev_queue_stopped", 0400, dentry, i2400m, |
---|
| 236 | + &fops_netdev_queue_stopped); |
---|
329 | 237 | |
---|
330 | | - fd = debugfs_create_file("rx_stats", 0600, dentry, i2400m, |
---|
331 | | - &i2400m_rx_stats_fops); |
---|
332 | | - result = PTR_ERR(fd); |
---|
333 | | - if (IS_ERR(fd) && result != -ENODEV) { |
---|
334 | | - dev_err(dev, "Can't create debugfs entry " |
---|
335 | | - "rx_stats: %d\n", result); |
---|
336 | | - goto error; |
---|
337 | | - } |
---|
| 238 | + debugfs_create_file("rx_stats", 0600, dentry, i2400m, |
---|
| 239 | + &i2400m_rx_stats_fops); |
---|
338 | 240 | |
---|
339 | | - fd = debugfs_create_file("tx_stats", 0600, dentry, i2400m, |
---|
340 | | - &i2400m_tx_stats_fops); |
---|
341 | | - result = PTR_ERR(fd); |
---|
342 | | - if (IS_ERR(fd) && result != -ENODEV) { |
---|
343 | | - dev_err(dev, "Can't create debugfs entry " |
---|
344 | | - "tx_stats: %d\n", result); |
---|
345 | | - goto error; |
---|
346 | | - } |
---|
| 241 | + debugfs_create_file("tx_stats", 0600, dentry, i2400m, |
---|
| 242 | + &i2400m_tx_stats_fops); |
---|
347 | 243 | |
---|
348 | | - fd = debugfs_create_i2400m_suspend("suspend", dentry, i2400m); |
---|
349 | | - result = PTR_ERR(fd); |
---|
350 | | - if (IS_ERR(fd) && result != -ENODEV) { |
---|
351 | | - dev_err(dev, "Can't create debugfs entry suspend: %d\n", |
---|
352 | | - result); |
---|
353 | | - goto error; |
---|
354 | | - } |
---|
| 244 | + debugfs_create_file("suspend", 0200, dentry, i2400m, |
---|
| 245 | + &fops_i2400m_suspend); |
---|
355 | 246 | |
---|
356 | | - fd = debugfs_create_i2400m_reset("reset", dentry, i2400m); |
---|
357 | | - result = PTR_ERR(fd); |
---|
358 | | - if (IS_ERR(fd) && result != -ENODEV) { |
---|
359 | | - dev_err(dev, "Can't create debugfs entry reset: %d\n", result); |
---|
360 | | - goto error; |
---|
361 | | - } |
---|
362 | | - |
---|
363 | | - result = 0; |
---|
364 | | -error: |
---|
365 | | - return result; |
---|
| 247 | + debugfs_create_file("reset", 0200, dentry, i2400m, &fops_i2400m_reset); |
---|
366 | 248 | } |
---|
367 | 249 | |
---|
368 | 250 | void i2400m_debugfs_rm(struct i2400m *i2400m) |
---|