debugfs.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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 device;
  20. struct file_operations;
  21. struct debugfs_blob_wrapper {
  22. void *data;
  23. unsigned long size;
  24. };
  25. struct debugfs_reg32 {
  26. char *name;
  27. unsigned long offset;
  28. };
  29. struct debugfs_regset32 {
  30. const struct debugfs_reg32 *regs;
  31. int nregs;
  32. void __iomem *base;
  33. };
  34. extern struct dentry *arch_debugfs_dir;
  35. #if defined(CONFIG_DEBUG_FS)
  36. /* declared over in file.c */
  37. extern const struct file_operations debugfs_file_operations;
  38. extern const struct inode_operations debugfs_link_operations;
  39. struct dentry *debugfs_create_file(const char *name, umode_t mode,
  40. struct dentry *parent, void *data,
  41. const struct file_operations *fops);
  42. struct dentry *debugfs_create_file_size(const char *name, umode_t mode,
  43. struct dentry *parent, void *data,
  44. const struct file_operations *fops,
  45. loff_t file_size);
  46. struct dentry *debugfs_create_dir(const char *name, struct dentry *parent);
  47. struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent,
  48. const char *dest);
  49. struct dentry *debugfs_create_automount(const char *name,
  50. struct dentry *parent,
  51. struct vfsmount *(*f)(void *),
  52. void *data);
  53. void debugfs_remove(struct dentry *dentry);
  54. void debugfs_remove_recursive(struct dentry *dentry);
  55. struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
  56. struct dentry *new_dir, const char *new_name);
  57. struct dentry *debugfs_create_u8(const char *name, umode_t mode,
  58. struct dentry *parent, u8 *value);
  59. struct dentry *debugfs_create_u16(const char *name, umode_t mode,
  60. struct dentry *parent, u16 *value);
  61. struct dentry *debugfs_create_u32(const char *name, umode_t mode,
  62. struct dentry *parent, u32 *value);
  63. struct dentry *debugfs_create_u64(const char *name, umode_t mode,
  64. struct dentry *parent, u64 *value);
  65. struct dentry *debugfs_create_x8(const char *name, umode_t mode,
  66. struct dentry *parent, u8 *value);
  67. struct dentry *debugfs_create_x16(const char *name, umode_t mode,
  68. struct dentry *parent, u16 *value);
  69. struct dentry *debugfs_create_x32(const char *name, umode_t mode,
  70. struct dentry *parent, u32 *value);
  71. struct dentry *debugfs_create_x64(const char *name, umode_t mode,
  72. struct dentry *parent, u64 *value);
  73. struct dentry *debugfs_create_size_t(const char *name, umode_t mode,
  74. struct dentry *parent, size_t *value);
  75. struct dentry *debugfs_create_atomic_t(const char *name, umode_t mode,
  76. struct dentry *parent, atomic_t *value);
  77. struct dentry *debugfs_create_bool(const char *name, umode_t mode,
  78. struct dentry *parent, u32 *value);
  79. struct dentry *debugfs_create_blob(const char *name, umode_t mode,
  80. struct dentry *parent,
  81. struct debugfs_blob_wrapper *blob);
  82. struct dentry *debugfs_create_regset32(const char *name, umode_t mode,
  83. struct dentry *parent,
  84. struct debugfs_regset32 *regset);
  85. void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs,
  86. int nregs, void __iomem *base, char *prefix);
  87. struct dentry *debugfs_create_u32_array(const char *name, umode_t mode,
  88. struct dentry *parent,
  89. u32 *array, u32 elements);
  90. struct dentry *debugfs_create_devm_seqfile(struct device *dev, const char *name,
  91. struct dentry *parent,
  92. int (*read_fn)(struct seq_file *s,
  93. void *data));
  94. bool debugfs_initialized(void);
  95. #else
  96. #include <linux/err.h>
  97. /*
  98. * We do not return NULL from these functions if CONFIG_DEBUG_FS is not enabled
  99. * so users have a chance to detect if there was a real error or not. We don't
  100. * want to duplicate the design decision mistakes of procfs and devfs again.
  101. */
  102. static inline struct dentry *debugfs_create_file(const char *name, umode_t mode,
  103. struct dentry *parent, void *data,
  104. const struct file_operations *fops)
  105. {
  106. return ERR_PTR(-ENODEV);
  107. }
  108. static inline struct dentry *debugfs_create_file_size(const char *name, umode_t mode,
  109. struct dentry *parent, void *data,
  110. const struct file_operations *fops,
  111. loff_t file_size)
  112. {
  113. return ERR_PTR(-ENODEV);
  114. }
  115. static inline struct dentry *debugfs_create_dir(const char *name,
  116. struct dentry *parent)
  117. {
  118. return ERR_PTR(-ENODEV);
  119. }
  120. static inline struct dentry *debugfs_create_symlink(const char *name,
  121. struct dentry *parent,
  122. const char *dest)
  123. {
  124. return ERR_PTR(-ENODEV);
  125. }
  126. static inline void debugfs_remove(struct dentry *dentry)
  127. { }
  128. static inline void debugfs_remove_recursive(struct dentry *dentry)
  129. { }
  130. static inline struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
  131. struct dentry *new_dir, char *new_name)
  132. {
  133. return ERR_PTR(-ENODEV);
  134. }
  135. static inline struct dentry *debugfs_create_u8(const char *name, umode_t mode,
  136. struct dentry *parent,
  137. u8 *value)
  138. {
  139. return ERR_PTR(-ENODEV);
  140. }
  141. static inline struct dentry *debugfs_create_u16(const char *name, umode_t mode,
  142. struct dentry *parent,
  143. u16 *value)
  144. {
  145. return ERR_PTR(-ENODEV);
  146. }
  147. static inline struct dentry *debugfs_create_u32(const char *name, umode_t mode,
  148. struct dentry *parent,
  149. u32 *value)
  150. {
  151. return ERR_PTR(-ENODEV);
  152. }
  153. static inline struct dentry *debugfs_create_u64(const char *name, umode_t mode,
  154. struct dentry *parent,
  155. u64 *value)
  156. {
  157. return ERR_PTR(-ENODEV);
  158. }
  159. static inline struct dentry *debugfs_create_x8(const char *name, umode_t mode,
  160. struct dentry *parent,
  161. u8 *value)
  162. {
  163. return ERR_PTR(-ENODEV);
  164. }
  165. static inline struct dentry *debugfs_create_x16(const char *name, umode_t mode,
  166. struct dentry *parent,
  167. u16 *value)
  168. {
  169. return ERR_PTR(-ENODEV);
  170. }
  171. static inline struct dentry *debugfs_create_x32(const char *name, umode_t mode,
  172. struct dentry *parent,
  173. u32 *value)
  174. {
  175. return ERR_PTR(-ENODEV);
  176. }
  177. static inline struct dentry *debugfs_create_x64(const char *name, umode_t mode,
  178. struct dentry *parent,
  179. u64 *value)
  180. {
  181. return ERR_PTR(-ENODEV);
  182. }
  183. static inline struct dentry *debugfs_create_size_t(const char *name, umode_t mode,
  184. struct dentry *parent,
  185. size_t *value)
  186. {
  187. return ERR_PTR(-ENODEV);
  188. }
  189. static inline struct dentry *debugfs_create_atomic_t(const char *name, umode_t mode,
  190. struct dentry *parent, atomic_t *value)
  191. {
  192. return ERR_PTR(-ENODEV);
  193. }
  194. static inline struct dentry *debugfs_create_bool(const char *name, umode_t mode,
  195. struct dentry *parent,
  196. u32 *value)
  197. {
  198. return ERR_PTR(-ENODEV);
  199. }
  200. static inline struct dentry *debugfs_create_blob(const char *name, umode_t mode,
  201. struct dentry *parent,
  202. struct debugfs_blob_wrapper *blob)
  203. {
  204. return ERR_PTR(-ENODEV);
  205. }
  206. static inline struct dentry *debugfs_create_regset32(const char *name,
  207. umode_t mode, struct dentry *parent,
  208. struct debugfs_regset32 *regset)
  209. {
  210. return ERR_PTR(-ENODEV);
  211. }
  212. static inline void debugfs_print_regs32(struct seq_file *s, const struct debugfs_reg32 *regs,
  213. int nregs, void __iomem *base, char *prefix)
  214. {
  215. }
  216. static inline bool debugfs_initialized(void)
  217. {
  218. return false;
  219. }
  220. static inline struct dentry *debugfs_create_u32_array(const char *name, umode_t mode,
  221. struct dentry *parent,
  222. u32 *array, u32 elements)
  223. {
  224. return ERR_PTR(-ENODEV);
  225. }
  226. static inline struct dentry *debugfs_create_devm_seqfile(struct device *dev,
  227. const char *name,
  228. struct dentry *parent,
  229. int (*read_fn)(struct seq_file *s,
  230. void *data))
  231. {
  232. return ERR_PTR(-ENODEV);
  233. }
  234. #endif
  235. #endif