debugfs.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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_create_u8(const char *name, mode_t mode,
  32. struct dentry *parent, u8 *value);
  33. struct dentry *debugfs_create_u16(const char *name, mode_t mode,
  34. struct dentry *parent, u16 *value);
  35. struct dentry *debugfs_create_u32(const char *name, mode_t mode,
  36. struct dentry *parent, u32 *value);
  37. struct dentry *debugfs_create_u64(const char *name, mode_t mode,
  38. struct dentry *parent, u64 *value);
  39. struct dentry *debugfs_create_bool(const char *name, mode_t mode,
  40. struct dentry *parent, u32 *value);
  41. struct dentry *debugfs_create_blob(const char *name, mode_t mode,
  42. struct dentry *parent,
  43. struct debugfs_blob_wrapper *blob);
  44. #else
  45. #include <linux/err.h>
  46. /*
  47. * We do not return NULL from these functions if CONFIG_DEBUG_FS is not enabled
  48. * so users have a chance to detect if there was a real error or not. We don't
  49. * want to duplicate the design decision mistakes of procfs and devfs again.
  50. */
  51. static inline struct dentry *debugfs_create_file(const char *name, mode_t mode,
  52. struct dentry *parent, void *data,
  53. const struct file_operations *fops)
  54. {
  55. return ERR_PTR(-ENODEV);
  56. }
  57. static inline struct dentry *debugfs_create_dir(const char *name,
  58. struct dentry *parent)
  59. {
  60. return ERR_PTR(-ENODEV);
  61. }
  62. static inline struct dentry *debugfs_create_symlink(const char *name,
  63. struct dentry *parent,
  64. const char *dest)
  65. {
  66. return ERR_PTR(-ENODEV);
  67. }
  68. static inline void debugfs_remove(struct dentry *dentry)
  69. { }
  70. static inline struct dentry *debugfs_create_u8(const char *name, mode_t mode,
  71. struct dentry *parent,
  72. u8 *value)
  73. {
  74. return ERR_PTR(-ENODEV);
  75. }
  76. static inline struct dentry *debugfs_create_u16(const char *name, mode_t mode,
  77. struct dentry *parent,
  78. u16 *value)
  79. {
  80. return ERR_PTR(-ENODEV);
  81. }
  82. static inline struct dentry *debugfs_create_u32(const char *name, mode_t mode,
  83. struct dentry *parent,
  84. u32 *value)
  85. {
  86. return ERR_PTR(-ENODEV);
  87. }
  88. static inline struct dentry *debugfs_create_u64(const char *name, mode_t mode,
  89. struct dentry *parent,
  90. u64 *value)
  91. {
  92. return ERR_PTR(-ENODEV);
  93. }
  94. static inline struct dentry *debugfs_create_bool(const char *name, mode_t mode,
  95. struct dentry *parent,
  96. u32 *value)
  97. {
  98. return ERR_PTR(-ENODEV);
  99. }
  100. static inline struct dentry *debugfs_create_blob(const char *name, mode_t mode,
  101. struct dentry *parent,
  102. struct debugfs_blob_wrapper *blob)
  103. {
  104. return ERR_PTR(-ENODEV);
  105. }
  106. #endif
  107. #endif