debugfs.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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/filesystems for more details.
  13. */
  14. #ifndef _DEBUGFS_H_
  15. #define _DEBUGFS_H_
  16. #include <linux/fs.h>
  17. #include <linux/seq_file.h>
  18. #include <linux/types.h>
  19. struct file_operations;
  20. struct debugfs_blob_wrapper {
  21. void *data;
  22. unsigned long size;
  23. };
  24. struct debugfs_reg32 {
  25. char *name;
  26. unsigned long offset;
  27. };
  28. struct debugfs_regset32 {
  29. struct debugfs_reg32 *regs;
  30. int nregs;
  31. void __iomem *base;
  32. };
  33. extern struct dentry *arch_debugfs_dir;
  34. #if defined(CONFIG_DEBUG_FS)
  35. /* declared over in file.c */
  36. extern const struct file_operations debugfs_file_operations;
  37. extern const struct inode_operations debugfs_link_operations;
  38. struct dentry *debugfs_create_file(const char *name, umode_t mode,
  39. struct dentry *parent, void *data,
  40. const struct file_operations *fops);
  41. struct dentry *debugfs_create_dir(const char *name, struct dentry *parent);
  42. struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent,
  43. const char *dest);
  44. void debugfs_remove(struct dentry *dentry);
  45. void debugfs_remove_recursive(struct dentry *dentry);
  46. struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
  47. struct dentry *new_dir, const char *new_name);
  48. struct dentry *debugfs_create_u8(const char *name, umode_t mode,
  49. struct dentry *parent, u8 *value);
  50. struct dentry *debugfs_create_u16(const char *name, umode_t mode,
  51. struct dentry *parent, u16 *value);
  52. struct dentry *debugfs_create_u32(const char *name, umode_t mode,
  53. struct dentry *parent, u32 *value);
  54. struct dentry *debugfs_create_u64(const char *name, umode_t mode,
  55. struct dentry *parent, u64 *value);
  56. struct dentry *debugfs_create_x8(const char *name, umode_t mode,
  57. struct dentry *parent, u8 *value);
  58. struct dentry *debugfs_create_x16(const char *name, umode_t mode,
  59. struct dentry *parent, u16 *value);
  60. struct dentry *debugfs_create_x32(const char *name, umode_t mode,
  61. struct dentry *parent, u32 *value);
  62. struct dentry *debugfs_create_x64(const char *name, umode_t mode,
  63. struct dentry *parent, u64 *value);
  64. struct dentry *debugfs_create_size_t(const char *name, umode_t mode,
  65. struct dentry *parent, size_t *value);
  66. struct dentry *debugfs_create_atomic_t(const char *name, umode_t mode,
  67. struct dentry *parent, atomic_t *value);
  68. struct dentry *debugfs_create_bool(const char *name, umode_t mode,
  69. struct dentry *parent, u32 *value);
  70. struct dentry *debugfs_create_blob(const char *name, umode_t mode,
  71. struct dentry *parent,
  72. struct debugfs_blob_wrapper *blob);
  73. struct dentry *debugfs_create_regset32(const char *name, umode_t mode,
  74. struct dentry *parent,
  75. struct debugfs_regset32 *regset);
  76. int debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs,
  77. int nregs, void __iomem *base, char *prefix);
  78. bool debugfs_initialized(void);
  79. #else
  80. #include <linux/err.h>
  81. /*
  82. * We do not return NULL from these functions if CONFIG_DEBUG_FS is not enabled
  83. * so users have a chance to detect if there was a real error or not. We don't
  84. * want to duplicate the design decision mistakes of procfs and devfs again.
  85. */
  86. static inline struct dentry *debugfs_create_file(const char *name, umode_t mode,
  87. struct dentry *parent, void *data,
  88. const struct file_operations *fops)
  89. {
  90. return ERR_PTR(-ENODEV);
  91. }
  92. static inline struct dentry *debugfs_create_dir(const char *name,
  93. struct dentry *parent)
  94. {
  95. return ERR_PTR(-ENODEV);
  96. }
  97. static inline struct dentry *debugfs_create_symlink(const char *name,
  98. struct dentry *parent,
  99. const char *dest)
  100. {
  101. return ERR_PTR(-ENODEV);
  102. }
  103. static inline void debugfs_remove(struct dentry *dentry)
  104. { }
  105. static inline void debugfs_remove_recursive(struct dentry *dentry)
  106. { }
  107. static inline struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
  108. struct dentry *new_dir, char *new_name)
  109. {
  110. return ERR_PTR(-ENODEV);
  111. }
  112. static inline struct dentry *debugfs_create_u8(const char *name, umode_t mode,
  113. struct dentry *parent,
  114. u8 *value)
  115. {
  116. return ERR_PTR(-ENODEV);
  117. }
  118. static inline struct dentry *debugfs_create_u16(const char *name, umode_t mode,
  119. struct dentry *parent,
  120. u16 *value)
  121. {
  122. return ERR_PTR(-ENODEV);
  123. }
  124. static inline struct dentry *debugfs_create_u32(const char *name, umode_t mode,
  125. struct dentry *parent,
  126. u32 *value)
  127. {
  128. return ERR_PTR(-ENODEV);
  129. }
  130. static inline struct dentry *debugfs_create_u64(const char *name, umode_t mode,
  131. struct dentry *parent,
  132. u64 *value)
  133. {
  134. return ERR_PTR(-ENODEV);
  135. }
  136. static inline struct dentry *debugfs_create_x8(const char *name, umode_t mode,
  137. struct dentry *parent,
  138. u8 *value)
  139. {
  140. return ERR_PTR(-ENODEV);
  141. }
  142. static inline struct dentry *debugfs_create_x16(const char *name, umode_t mode,
  143. struct dentry *parent,
  144. u16 *value)
  145. {
  146. return ERR_PTR(-ENODEV);
  147. }
  148. static inline struct dentry *debugfs_create_x32(const char *name, umode_t mode,
  149. struct dentry *parent,
  150. u32 *value)
  151. {
  152. return ERR_PTR(-ENODEV);
  153. }
  154. static inline struct dentry *debugfs_create_size_t(const char *name, umode_t mode,
  155. struct dentry *parent,
  156. size_t *value)
  157. {
  158. return ERR_PTR(-ENODEV);
  159. }
  160. static inline struct dentry *debugfs_create_bool(const char *name, umode_t mode,
  161. struct dentry *parent,
  162. u32 *value)
  163. {
  164. return ERR_PTR(-ENODEV);
  165. }
  166. static inline struct dentry *debugfs_create_blob(const char *name, umode_t mode,
  167. struct dentry *parent,
  168. struct debugfs_blob_wrapper *blob)
  169. {
  170. return ERR_PTR(-ENODEV);
  171. }
  172. static inline struct dentry *debugfs_create_regset32(const char *name,
  173. umode_t mode, struct dentry *parent,
  174. struct debugfs_regset32 *regset)
  175. {
  176. return ERR_PTR(-ENODEV);
  177. }
  178. static inline bool debugfs_initialized(void)
  179. {
  180. return false;
  181. }
  182. #endif
  183. #endif