debugfs.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. /* Debug framework control of debug levels */
  29. struct d_level D_LEVEL[] = {
  30. D_SUBMODULE_DEFINE(debugfs),
  31. D_SUBMODULE_DEFINE(id_table),
  32. D_SUBMODULE_DEFINE(op_msg),
  33. D_SUBMODULE_DEFINE(op_reset),
  34. D_SUBMODULE_DEFINE(op_rfkill),
  35. D_SUBMODULE_DEFINE(stack),
  36. };
  37. size_t D_LEVEL_SIZE = ARRAY_SIZE(D_LEVEL);
  38. #define __debugfs_register(prefix, name, parent) \
  39. do { \
  40. result = d_level_register_debugfs(prefix, name, parent); \
  41. if (result < 0) \
  42. goto error; \
  43. } while (0)
  44. int wimax_debugfs_add(struct wimax_dev *wimax_dev)
  45. {
  46. int result;
  47. struct net_device *net_dev = wimax_dev->net_dev;
  48. struct device *dev = net_dev->dev.parent;
  49. struct dentry *dentry;
  50. char buf[128];
  51. snprintf(buf, sizeof(buf), "wimax:%s", net_dev->name);
  52. dentry = debugfs_create_dir(buf, NULL);
  53. result = PTR_ERR(dentry);
  54. if (IS_ERR(dentry)) {
  55. if (result == -ENODEV)
  56. result = 0; /* No debugfs support */
  57. else
  58. dev_err(dev, "Can't create debugfs dentry: %d\n",
  59. result);
  60. goto out;
  61. }
  62. wimax_dev->debugfs_dentry = dentry;
  63. __debugfs_register("wimax_dl_", debugfs, dentry);
  64. __debugfs_register("wimax_dl_", id_table, dentry);
  65. __debugfs_register("wimax_dl_", op_msg, dentry);
  66. __debugfs_register("wimax_dl_", op_reset, dentry);
  67. __debugfs_register("wimax_dl_", op_rfkill, dentry);
  68. __debugfs_register("wimax_dl_", stack, dentry);
  69. result = 0;
  70. out:
  71. return result;
  72. error:
  73. debugfs_remove_recursive(wimax_dev->debugfs_dentry);
  74. return result;
  75. }
  76. void wimax_debugfs_rm(struct wimax_dev *wimax_dev)
  77. {
  78. debugfs_remove_recursive(wimax_dev->debugfs_dentry);
  79. }