debugfs.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. #if defined(CONFIG_DEBUG_FS)
  20. struct dentry *debugfs_create_file(const char *name, mode_t mode,
  21. struct dentry *parent, void *data,
  22. struct file_operations *fops);
  23. struct dentry *debugfs_create_dir(const char *name, struct dentry *parent);
  24. void debugfs_remove(struct dentry *dentry);
  25. struct dentry *debugfs_create_u8(const char *name, mode_t mode,
  26. struct dentry *parent, u8 *value);
  27. struct dentry *debugfs_create_u16(const char *name, mode_t mode,
  28. struct dentry *parent, u16 *value);
  29. struct dentry *debugfs_create_u32(const char *name, mode_t mode,
  30. struct dentry *parent, u32 *value);
  31. struct dentry *debugfs_create_bool(const char *name, mode_t mode,
  32. struct dentry *parent, u32 *value);
  33. #else
  34. #include <linux/err.h>
  35. /*
  36. * We do not return NULL from these functions if CONFIG_DEBUG_FS is not enabled
  37. * so users have a chance to detect if there was a real error or not. We don't
  38. * want to duplicate the design decision mistakes of procfs and devfs again.
  39. */
  40. static inline struct dentry *debugfs_create_file(const char *name, mode_t mode,
  41. struct dentry *parent,
  42. void *data,
  43. struct file_operations *fops)
  44. {
  45. return ERR_PTR(-ENODEV);
  46. }
  47. static inline struct dentry *debugfs_create_dir(const char *name,
  48. struct dentry *parent)
  49. {
  50. return ERR_PTR(-ENODEV);
  51. }
  52. static inline void debugfs_remove(struct dentry *dentry)
  53. { }
  54. static inline struct dentry *debugfs_create_u8(const char *name, mode_t mode,
  55. struct dentry *parent,
  56. u8 *value)
  57. {
  58. return ERR_PTR(-ENODEV);
  59. }
  60. static inline struct dentry *debugfs_create_u16(const char *name, mode_t mode,
  61. struct dentry *parent,
  62. u16 *value)
  63. {
  64. return ERR_PTR(-ENODEV);
  65. }
  66. static inline struct dentry *debugfs_create_u32(const char *name, mode_t mode,
  67. struct dentry *parent,
  68. u32 *value)
  69. {
  70. return ERR_PTR(-ENODEV);
  71. }
  72. static inline struct dentry *debugfs_create_bool(const char *name, mode_t mode,
  73. struct dentry *parent,
  74. u32 *value)
  75. {
  76. return ERR_PTR(-ENODEV);
  77. }
  78. #endif
  79. #endif