Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / ras / debugfs.c
blob0d4f985afbf37f92e9f0f54531f2dd58248ee877
1 // SPDX-License-Identifier: GPL-2.0-only
2 #include <linux/debugfs.h>
3 #include <linux/ras.h>
4 #include "debugfs.h"
6 struct dentry *ras_debugfs_dir;
8 static atomic_t trace_count = ATOMIC_INIT(0);
10 int ras_userspace_consumers(void)
12 return atomic_read(&trace_count);
14 EXPORT_SYMBOL_GPL(ras_userspace_consumers);
16 static int trace_show(struct seq_file *m, void *v)
18 return atomic_read(&trace_count);
21 static int trace_open(struct inode *inode, struct file *file)
23 atomic_inc(&trace_count);
24 return single_open(file, trace_show, NULL);
27 static int trace_release(struct inode *inode, struct file *file)
29 atomic_dec(&trace_count);
30 return single_release(inode, file);
33 static const struct file_operations trace_fops = {
34 .open = trace_open,
35 .read = seq_read,
36 .llseek = seq_lseek,
37 .release = trace_release,
40 int __init ras_add_daemon_trace(void)
42 struct dentry *fentry;
44 if (!ras_debugfs_dir)
45 return -ENOENT;
47 fentry = debugfs_create_file("daemon_active", S_IRUSR, ras_debugfs_dir,
48 NULL, &trace_fops);
49 if (!fentry)
50 return -ENODEV;
52 return 0;
56 void __init ras_debugfs_init(void)
58 ras_debugfs_dir = debugfs_create_dir("ras", NULL);