0001
0002 #include <linux/debugfs.h>
0003 #include <linux/ras.h>
0004 #include "debugfs.h"
0005
0006 struct dentry *ras_debugfs_dir;
0007
0008 static atomic_t trace_count = ATOMIC_INIT(0);
0009
0010 int ras_userspace_consumers(void)
0011 {
0012 return atomic_read(&trace_count);
0013 }
0014 EXPORT_SYMBOL_GPL(ras_userspace_consumers);
0015
0016 static int trace_show(struct seq_file *m, void *v)
0017 {
0018 return atomic_read(&trace_count);
0019 }
0020
0021 static int trace_open(struct inode *inode, struct file *file)
0022 {
0023 atomic_inc(&trace_count);
0024 return single_open(file, trace_show, NULL);
0025 }
0026
0027 static int trace_release(struct inode *inode, struct file *file)
0028 {
0029 atomic_dec(&trace_count);
0030 return single_release(inode, file);
0031 }
0032
0033 static const struct file_operations trace_fops = {
0034 .open = trace_open,
0035 .read = seq_read,
0036 .llseek = seq_lseek,
0037 .release = trace_release,
0038 };
0039
0040 int __init ras_add_daemon_trace(void)
0041 {
0042 struct dentry *fentry;
0043
0044 if (!ras_debugfs_dir)
0045 return -ENOENT;
0046
0047 fentry = debugfs_create_file("daemon_active", S_IRUSR, ras_debugfs_dir,
0048 NULL, &trace_fops);
0049 if (!fentry)
0050 return -ENODEV;
0051
0052 return 0;
0053
0054 }
0055
0056 void __init ras_debugfs_init(void)
0057 {
0058 ras_debugfs_dir = debugfs_create_dir("ras", NULL);
0059 }