debugfs.h 2.5 KB

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