debugfs.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * debugfs.h - a tiny little debug file system
  3. *
  4. * Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com>
  5. * Copyright (C) 2004 IBM Inc.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License version
  9. * 2 as published by the Free Software Foundation.
  10. *
  11. * debugfs is for people to use instead of /proc or /sys.
  12. * See Documentation/DocBook/kernel-api for more details.
  13. */
  14. #ifndef _DEBUGFS_H_
  15. #define _DEBUGFS_H_
  16. #include <linux/fs.h>
  17. #include <linux/types.h>
  18. struct file_operations;
  19. struct debugfs_blob_wrapper {
  20. void *data;
  21. unsigned long size;
  22. };
  23. #if defined(CONFIG_DEBUG_FS)
  24. struct dentry *debugfs_create_file(const char *name, mode_t mode,
  25. struct dentry *parent, void *data,
  26. const struct file_operations *fops);
  27. struct dentry *debugfs_create_dir(const char *name, struct dentry *parent);
  28. struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent,
  29. const char *dest);
  30. void debugfs_remove(struct dentry *dentry);
  31. struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
  32. struct dentry *new_dir, const char *new_name);
  33. struct dentry *debugfs_create_u8(const char *name, mode_t mode,
  34. struct dentry *parent, u8 *value);
  35. struct dentry *debugfs_create_u16(const char *name, mode_t mode,
  36. struct dentry *parent, u16 *value);
  37. struct dentry *debugfs_create_u32(const char *name, mode_t mode,
  38. struct dentry *parent, u32 *value);
  39. struct dentry *debugfs_create_u64(const char *name, mode_t mode,
  40. struct dentry *parent, u64 *value);
  41. struct dentry *debugfs_create_x8(const char *name, mode_t mode,
  42. struct dentry *parent, u8 *value);
  43. struct dentry *debugfs_create_x16(const char *name, mode_t mode,
  44. struct dentry *parent, u16 *value);
  45. struct dentry *debugfs_create_x32(const char *name, mode_t mode,
  46. struct dentry *parent, u32 *value);
  47. struct dentry *debugfs_create_bool(const char *name, mode_t mode,
  48. struct dentry *parent, u32 *value);
  49. struct dentry *debugfs_create_blob(const char *name, mode_t mode,
  50. struct dentry *parent,
  51. struct debugfs_blob_wrapper *blob);
  52. #else
  53. #include <linux/err.h>
  54. /*
  55. * We do not return NULL from these functions if CONFIG_DEBUG_FS is not enabled
  56. * so users have a chance to detect if there was a real error or not. We don't
  57. * want to duplicate the design decision mistakes of procfs and devfs again.
  58. */
  59. static inline struct dentry *debugfs_create_file(const char *name, mode_t mode,
  60. struct dentry *parent, void *data,
  61. const struct file_operations *fops)
  62. {
  63. return ERR_PTR(-ENODEV);
  64. }
  65. static inline struct dentry *debugfs_create_dir(const char *name,
  66. struct dentry *parent)
  67. {
  68. return ERR_PTR(-ENODEV);
  69. }
  70. static inline struct dentry *debugfs_create_symlink(const char *name,
  71. struct dentry *parent,
  72. const char *dest)
  73. {
  74. return ERR_PTR(-ENODEV);
  75. }
  76. static inline void debugfs_remove(struct dentry *dentry)
  77. { }
  78. static inline struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
  79. struct dentry *new_dir, char *new_name)
  80. {
  81. return ERR_PTR(-ENODEV);
  82. }
  83. static inline struct dentry *debugfs_create_u8(const char *name, mode_t mode,
  84. struct dentry *parent,
  85. u8 *value)
  86. {
  87. return ERR_PTR(-ENODEV);
  88. }
  89. static inline struct dentry *debugfs_create_u16(const char *name, mode_t mode,
  90. struct dentry *parent,
  91. u16 *value)
  92. {
  93. return ERR_PTR(-ENODEV);
  94. }
  95. static inline struct dentry *debugfs_create_u32(const char *name, mode_t mode,
  96. struct dentry *parent,
  97. u32 *value)
  98. {
  99. return ERR_PTR(-ENODEV);
  100. }
  101. static inline struct dentry *debugfs_create_u64(const char *name, mode_t mode,
  102. struct dentry *parent,
  103. u64 *value)
  104. {
  105. return ERR_PTR(-ENODEV);
  106. }
  107. static inline struct dentry *debugfs_create_x8(const char *name, mode_t mode,
  108. struct dentry *parent,
  109. u8 *value)
  110. {
  111. return ERR_PTR(-ENODEV);
  112. }
  113. static inline struct dentry *debugfs_create_x16(const char *name, mode_t mode,
  114. struct dentry *parent,
  115. u16 *value)
  116. {
  117. return ERR_PTR(-ENODEV);
  118. }
  119. static inline struct dentry *debugfs_create_x32(const char *name, mode_t mode,
  120. struct dentry *parent,
  121. u32 *value)
  122. {
  123. return ERR_PTR(-ENODEV);
  124. }
  125. static inline struct dentry *debugfs_create_bool(const char *name, mode_t mode,
  126. struct dentry *parent,
  127. u32 *value)
  128. {
  129. return ERR_PTR(-ENODEV);
  130. }
  131. static inline struct dentry *debugfs_create_blob(const char *name, mode_t mode,
  132. struct dentry *parent,
  133. struct debugfs_blob_wrapper *blob)
  134. {
  135. return ERR_PTR(-ENODEV);
  136. }
  137. #endif
  138. #endif