1 // SPDX-License-Identifier: GPL-2.0-only
2 #include <linux/debugfs.h>
4 struct dentry
*ras_debugfs_dir
;
6 static atomic_t trace_count
= ATOMIC_INIT(0);
8 int ras_userspace_consumers(void)
10 return atomic_read(&trace_count
);
12 EXPORT_SYMBOL_GPL(ras_userspace_consumers
);
14 static int trace_show(struct seq_file
*m
, void *v
)
16 return atomic_read(&trace_count
);
19 static int trace_open(struct inode
*inode
, struct file
*file
)
21 atomic_inc(&trace_count
);
22 return single_open(file
, trace_show
, NULL
);
25 static int trace_release(struct inode
*inode
, struct file
*file
)
27 atomic_dec(&trace_count
);
28 return single_release(inode
, file
);
31 static const struct file_operations trace_fops
= {
35 .release
= trace_release
,
38 int __init
ras_add_daemon_trace(void)
40 struct dentry
*fentry
;
45 fentry
= debugfs_create_file("daemon_active", S_IRUSR
, ras_debugfs_dir
,
54 void __init
ras_debugfs_init(void)
56 ras_debugfs_dir
= debugfs_create_dir("ras", NULL
);