Thomas Gleixner | 04672fe | 2019-05-29 07:12:42 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Inaky Perez-Gonzalez | 617209c | 2008-12-20 16:57:40 -0800 | [diff] [blame] | 2 | /* |
| 3 | * Linux WiMAX |
| 4 | * Debugfs support |
| 5 | * |
Inaky Perez-Gonzalez | 617209c | 2008-12-20 16:57:40 -0800 | [diff] [blame] | 6 | * Copyright (C) 2005-2006 Intel Corporation <linux-wimax@intel.com> |
| 7 | * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> |
Inaky Perez-Gonzalez | 617209c | 2008-12-20 16:57:40 -0800 | [diff] [blame] | 8 | */ |
| 9 | #include <linux/debugfs.h> |
| 10 | #include <linux/wimax.h> |
| 11 | #include "wimax-internal.h" |
| 12 | |
| 13 | #define D_SUBMODULE debugfs |
| 14 | #include "debug-levels.h" |
| 15 | |
| 16 | |
Inaky Perez-Gonzalez | 617209c | 2008-12-20 16:57:40 -0800 | [diff] [blame] | 17 | #define __debugfs_register(prefix, name, parent) \ |
| 18 | do { \ |
| 19 | result = d_level_register_debugfs(prefix, name, parent); \ |
| 20 | if (result < 0) \ |
| 21 | goto error; \ |
| 22 | } while (0) |
| 23 | |
| 24 | |
| 25 | int wimax_debugfs_add(struct wimax_dev *wimax_dev) |
| 26 | { |
| 27 | int result; |
| 28 | struct net_device *net_dev = wimax_dev->net_dev; |
| 29 | struct device *dev = net_dev->dev.parent; |
| 30 | struct dentry *dentry; |
| 31 | char buf[128]; |
| 32 | |
| 33 | snprintf(buf, sizeof(buf), "wimax:%s", net_dev->name); |
| 34 | dentry = debugfs_create_dir(buf, NULL); |
| 35 | result = PTR_ERR(dentry); |
| 36 | if (IS_ERR(dentry)) { |
| 37 | if (result == -ENODEV) |
| 38 | result = 0; /* No debugfs support */ |
| 39 | else |
| 40 | dev_err(dev, "Can't create debugfs dentry: %d\n", |
| 41 | result); |
| 42 | goto out; |
| 43 | } |
| 44 | wimax_dev->debugfs_dentry = dentry; |
| 45 | __debugfs_register("wimax_dl_", debugfs, dentry); |
| 46 | __debugfs_register("wimax_dl_", id_table, dentry); |
| 47 | __debugfs_register("wimax_dl_", op_msg, dentry); |
| 48 | __debugfs_register("wimax_dl_", op_reset, dentry); |
| 49 | __debugfs_register("wimax_dl_", op_rfkill, dentry); |
Paulius Zaleckas | 7f0333e | 2009-05-13 06:20:29 -0700 | [diff] [blame] | 50 | __debugfs_register("wimax_dl_", op_state_get, dentry); |
Inaky Perez-Gonzalez | 617209c | 2008-12-20 16:57:40 -0800 | [diff] [blame] | 51 | __debugfs_register("wimax_dl_", stack, dentry); |
| 52 | result = 0; |
| 53 | out: |
| 54 | return result; |
| 55 | |
| 56 | error: |
| 57 | debugfs_remove_recursive(wimax_dev->debugfs_dentry); |
| 58 | return result; |
| 59 | } |
| 60 | |
| 61 | void wimax_debugfs_rm(struct wimax_dev *wimax_dev) |
| 62 | { |
| 63 | debugfs_remove_recursive(wimax_dev->debugfs_dentry); |
| 64 | } |