debugfs.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause */
  2. /*
  3. * Copyright(c) 2015, 2016, 2018 Intel Corporation.
  4. */
  5. #ifndef _HFI1_DEBUGFS_H
  6. #define _HFI1_DEBUGFS_H
  7. struct hfi1_ibdev;
  8. #define DEBUGFS_SEQ_FILE_OPS(name) \
  9. static const struct seq_operations _##name##_seq_ops = { \
  10. .start = _##name##_seq_start, \
  11. .next = _##name##_seq_next, \
  12. .stop = _##name##_seq_stop, \
  13. .show = _##name##_seq_show \
  14. }
  15. #define DEBUGFS_SEQ_FILE_OPEN(name) \
  16. static int _##name##_open(struct inode *inode, struct file *s) \
  17. { \
  18. struct seq_file *seq; \
  19. int ret; \
  20. ret = seq_open(s, &_##name##_seq_ops); \
  21. if (ret) \
  22. return ret; \
  23. seq = s->private_data; \
  24. seq->private = inode->i_private; \
  25. return 0; \
  26. }
  27. #define DEBUGFS_FILE_OPS(name) \
  28. static const struct file_operations _##name##_file_ops = { \
  29. .owner = THIS_MODULE, \
  30. .open = _##name##_open, \
  31. .read = hfi1_seq_read, \
  32. .llseek = hfi1_seq_lseek, \
  33. .release = seq_release \
  34. }
  35. ssize_t hfi1_seq_read(struct file *file, char __user *buf, size_t size,
  36. loff_t *ppos);
  37. loff_t hfi1_seq_lseek(struct file *file, loff_t offset, int whence);
  38. #ifdef CONFIG_DEBUG_FS
  39. void hfi1_dbg_ibdev_init(struct hfi1_ibdev *ibd);
  40. void hfi1_dbg_ibdev_exit(struct hfi1_ibdev *ibd);
  41. void hfi1_dbg_init(void);
  42. void hfi1_dbg_exit(void);
  43. #else
  44. static inline void hfi1_dbg_ibdev_init(struct hfi1_ibdev *ibd)
  45. {
  46. }
  47. static inline void hfi1_dbg_ibdev_exit(struct hfi1_ibdev *ibd)
  48. {
  49. }
  50. static inline void hfi1_dbg_init(void)
  51. {
  52. }
  53. static inline void hfi1_dbg_exit(void)
  54. {
  55. }
  56. #endif
  57. #endif /* _HFI1_DEBUGFS_H */