1 /* SPDX-License-Identifier: MIT */
3 * Copyright © 2019 Intel Corporation
6 #ifndef INTEL_GT_DEBUGFS_H
7 #define INTEL_GT_DEBUGFS_H
9 #include <linux/file.h>
13 #define __GT_DEBUGFS_ATTRIBUTE_FOPS(__name) \
14 static const struct file_operations __name ## _fops = { \
15 .owner = THIS_MODULE, \
16 .open = __name ## _open, \
18 .llseek = seq_lseek, \
19 .release = single_release, \
22 #define DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE(__name) \
23 static int __name ## _open(struct inode *inode, struct file *file) \
25 return single_open(file, __name ## _show, inode->i_private); \
27 __GT_DEBUGFS_ATTRIBUTE_FOPS(__name)
29 #define DEFINE_INTEL_GT_DEBUGFS_ATTRIBUTE_WITH_SIZE(__name, __size_vf) \
30 static int __name ## _open(struct inode *inode, struct file *file) \
32 return single_open_size(file, __name ## _show, inode->i_private, \
33 __size_vf(inode->i_private)); \
35 __GT_DEBUGFS_ATTRIBUTE_FOPS(__name)
37 void intel_gt_debugfs_register(struct intel_gt *gt);
39 struct intel_gt_debugfs_file {
41 const struct file_operations *fops;
42 bool (*eval)(void *data);
45 void intel_gt_debugfs_register_files(struct dentry *root,
46 const struct intel_gt_debugfs_file *files,
47 unsigned long count, void *data);
49 /* functions that need to be accessed by the upper level non-gt interfaces */
50 int intel_gt_debugfs_reset_show(struct intel_gt *gt, u64 *val);
51 void intel_gt_debugfs_reset_store(struct intel_gt *gt, u64 val);
53 #endif /* INTEL_GT_DEBUGFS_H */