debugfs.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. extern struct dentry *arch_debugfs_dir;
  24. #if defined(CONFIG_DEBUG_FS)
  25. /* declared over in file.c */
  26. extern const struct file_operations debugfs_file_operations;
  27. extern const struct inode_operations debugfs_link_operations;
  28. struct dentry *debugfs_create_file(const char *name, mode_t mode,
  29. struct dentry *parent, void *data,
  30. const struct file_operations *fops);
  31. struct dentry *debugfs_create_dir(const char *name, struct dentry *parent);
  32. struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent,
  33. const char *dest);
  34. void debugfs_remove(struct dentry *dentry);
  35. void debugfs_remove_recursive(struct dentry *dentry);
  36. struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
  37. struct dentry *new_dir, const char *new_name);
  38. struct dentry *debugfs_create_u8(const char *name, mode_t mode,
  39. struct dentry *parent, u8 *value);
  40. struct dentry *debugfs_create_u16(const char *name, mode_t mode,
  41. struct dentry *parent, u16 *value);
  42. struct dentry *debugfs_create_u32(const char *name, mode_t mode,
  43. struct dentry *parent, u32 *value);
  44. struct dentry *debugfs_create_u64(const char *name, mode_t mode,
  45. struct dentry *parent, u64 *value);
  46. struct dentry *debugfs_create_x8(const char *name, mode_t mode,
  47. struct dentry *parent, u8 *value);
  48. struct dentry *debugfs_create_x16(const char *name, mode_t mode,
  49. struct dentry *parent, u16 *value);
  50. struct dentry *debugfs_create_x32(const char *name, mode_t mode,
  51. struct dentry *parent, u32 *value);
  52. struct dentry *debugfs_create_bool(const char *name, mode_t mode,
  53. struct dentry *parent, u32 *value);
  54. struct dentry *debugfs_create_blob(const char *name, mode_t mode,
  55. struct dentry *parent,
  56. struct debugfs_blob_wrapper *blob);
  57. #else
  58. #include <linux/err.h>
  59. /*
  60. * We do not return NULL from these functions if CONFIG_DEBUG_FS is not enabled
  61. * so users have a chance to detect if there was a real error or not. We don't
  62. * want to duplicate the design decision mistakes of procfs and devfs again.
  63. */
  64. static inline struct dentry *debugfs_create_file(const char *name, mode_t mode,
  65. struct dentry *parent, void *data,
  66. const struct file_operations *fops)
  67. {
  68. return ERR_PTR(-ENODEV);
  69. }
  70. static inline struct dentry *debugfs_create_dir(const char *name,
  71. struct dentry *parent)
  72. {
  73. return ERR_PTR(-ENODEV);
  74. }
  75. static inline struct dentry *debugfs_create_symlink(const char *name,
  76. struct dentry *parent,
  77. const char *dest)
  78. {
  79. return ERR_PTR(-ENODEV);
  80. }
  81. static inline void debugfs_remove(struct dentry *dentry)
  82. { }
  83. static inline void debugfs_remove_recursive(struct dentry *dentry)
  84. { }
  85. static inline struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
  86. struct dentry *new_dir, char *new_name)
  87. {
  88. return ERR_PTR(-ENODEV);
  89. }
  90. static inline struct dentry *debugfs_create_u8(const char *name, mode_t mode,
  91. struct dentry *parent,
  92. u8 *value)
  93. {
  94. return ERR_PTR(-ENODEV);
  95. }
  96. static inline struct dentry *debugfs_create_u16(const char *name, mode_t mode,
  97. struct dentry *parent,
  98. u16 *value)
  99. {
  100. return ERR_PTR(-ENODEV);
  101. }
  102. static inline struct dentry *debugfs_create_u32(const char *name, mode_t mode,
  103. struct dentry *parent,
  104. u32 *value)
  105. {
  106. return ERR_PTR(-ENODEV);
  107. }
  108. static inline struct dentry *debugfs_create_u64(const char *name, mode_t mode,
  109. struct dentry *parent,
  110. u64 *value)
  111. {
  112. return ERR_PTR(-ENODEV);
  113. }
  114. static inline struct dentry *debugfs_create_x8(const char *name, mode_t mode,
  115. struct dentry *parent,
  116. u8 *value)
  117. {
  118. return ERR_PTR(-ENODEV);
  119. }
  120. static inline struct dentry *debugfs_create_x16(const char *name, mode_t mode,
  121. struct dentry *parent,
  122. u16 *value)
  123. {
  124. return ERR_PTR(-ENODEV);
  125. }
  126. static inline struct dentry *debugfs_create_x32(const char *name, mode_t mode,
  127. struct dentry *parent,
  128. u32 *value)
  129. {
  130. return ERR_PTR(-ENODEV);
  131. }
  132. static inline struct dentry *debugfs_create_bool(const char *name, mode_t mode,
  133. struct dentry *parent,
  134. u32 *value)
  135. {
  136. return ERR_PTR(-ENODEV);
  137. }
  138. static inline struct dentry *debugfs_create_blob(const char *name, mode_t mode,
  139. struct dentry *parent,
  140. struct debugfs_blob_wrapper *blob)
  141. {
  142. return ERR_PTR(-ENODEV);
  143. }
  144. #endif
  145. #endif