debugfs.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Linux WiMAX
  3. * Debugfs support
  4. *
  5. *
  6. * Copyright (C) 2005-2006 Intel Corporation <linux-wimax@intel.com>
  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. */
  23. #include <linux/debugfs.h>
  24. #include <linux/wimax.h>
  25. #include "wimax-internal.h"
  26. #define D_SUBMODULE debugfs
  27. #include "debug-levels.h"
  28. #define __debugfs_register(prefix, name, parent) \
  29. do { \
  30. result = d_level_register_debugfs(prefix, name, parent); \
  31. if (result < 0) \
  32. goto error; \
  33. } while (0)
  34. int wimax_debugfs_add(struct wimax_dev *wimax_dev)
  35. {
  36. int result;
  37. struct net_device *net_dev = wimax_dev->net_dev;
  38. struct device *dev = net_dev->dev.parent;
  39. struct dentry *dentry;
  40. char buf[128];
  41. snprintf(buf, sizeof(buf), "wimax:%s", net_dev->name);
  42. dentry = debugfs_create_dir(buf, NULL);
  43. result = PTR_ERR(dentry);
  44. if (IS_ERR(dentry)) {
  45. if (result == -ENODEV)
  46. result = 0; /* No debugfs support */
  47. else
  48. dev_err(dev, "Can't create debugfs dentry: %d\n",
  49. result);
  50. goto out;
  51. }
  52. wimax_dev->debugfs_dentry = dentry;
  53. __debugfs_register("wimax_dl_", debugfs, dentry);
  54. __debugfs_register("wimax_dl_", id_table, dentry);
  55. __debugfs_register("wimax_dl_", op_msg, dentry);
  56. __debugfs_register("wimax_dl_", op_reset, dentry);
  57. __debugfs_register("wimax_dl_", op_rfkill, dentry);
  58. __debugfs_register("wimax_dl_", op_state_get, dentry);
  59. __debugfs_register("wimax_dl_", stack, dentry);
  60. result = 0;
  61. out:
  62. return result;
  63. error:
  64. debugfs_remove_recursive(wimax_dev->debugfs_dentry);
  65. return result;
  66. }
  67. void wimax_debugfs_rm(struct wimax_dev *wimax_dev)
  68. {
  69. debugfs_remove_recursive(wimax_dev->debugfs_dentry);
  70. }