staging: rtl8188eu: remove unused code
[linux/fpc-iii.git] / drivers / edac / debugfs.c
blob6b8e484db851235616416f8eb79f70ba6079587f
1 // SPDX-License-Identifier: GPL-2.0-only
2 #include "edac_module.h"
4 static struct dentry *edac_debugfs;
6 static ssize_t edac_fake_inject_write(struct file *file,
7 const char __user *data,
8 size_t count, loff_t *ppos)
10 struct device *dev = file->private_data;
11 struct mem_ctl_info *mci = to_mci(dev);
12 static enum hw_event_mc_err_type type;
13 u16 errcount = mci->fake_inject_count;
15 if (!errcount)
16 errcount = 1;
18 type = mci->fake_inject_ue ? HW_EVENT_ERR_UNCORRECTED
19 : HW_EVENT_ERR_CORRECTED;
21 printk(KERN_DEBUG
22 "Generating %d %s fake error%s to %d.%d.%d to test core handling. NOTE: this won't test the driver-specific decoding logic.\n",
23 errcount,
24 (type == HW_EVENT_ERR_UNCORRECTED) ? "UE" : "CE",
25 errcount > 1 ? "s" : "",
26 mci->fake_inject_layer[0],
27 mci->fake_inject_layer[1],
28 mci->fake_inject_layer[2]
30 edac_mc_handle_error(type, mci, errcount, 0, 0, 0,
31 mci->fake_inject_layer[0],
32 mci->fake_inject_layer[1],
33 mci->fake_inject_layer[2],
34 "FAKE ERROR", "for EDAC testing only");
36 return count;
39 static const struct file_operations debug_fake_inject_fops = {
40 .open = simple_open,
41 .write = edac_fake_inject_write,
42 .llseek = generic_file_llseek,
45 void __init edac_debugfs_init(void)
47 edac_debugfs = debugfs_create_dir("edac", NULL);
50 void edac_debugfs_exit(void)
52 debugfs_remove_recursive(edac_debugfs);
55 void edac_create_debugfs_nodes(struct mem_ctl_info *mci)
57 struct dentry *parent;
58 char name[80];
59 int i;
61 parent = debugfs_create_dir(mci->dev.kobj.name, edac_debugfs);
63 for (i = 0; i < mci->n_layers; i++) {
64 sprintf(name, "fake_inject_%s",
65 edac_layer_name[mci->layers[i].type]);
66 debugfs_create_u8(name, S_IRUGO | S_IWUSR, parent,
67 &mci->fake_inject_layer[i]);
70 debugfs_create_bool("fake_inject_ue", S_IRUGO | S_IWUSR, parent,
71 &mci->fake_inject_ue);
73 debugfs_create_u16("fake_inject_count", S_IRUGO | S_IWUSR, parent,
74 &mci->fake_inject_count);
76 debugfs_create_file("fake_inject", S_IWUSR, parent, &mci->dev,
77 &debug_fake_inject_fops);
79 mci->debugfs = parent;
82 /* Create a toplevel dir under EDAC's debugfs hierarchy */
83 struct dentry *edac_debugfs_create_dir(const char *dirname)
85 if (!edac_debugfs)
86 return NULL;
88 return debugfs_create_dir(dirname, edac_debugfs);
90 EXPORT_SYMBOL_GPL(edac_debugfs_create_dir);
92 /* Create a toplevel dir under EDAC's debugfs hierarchy with parent @parent */
93 struct dentry *
94 edac_debugfs_create_dir_at(const char *dirname, struct dentry *parent)
96 return debugfs_create_dir(dirname, parent);
98 EXPORT_SYMBOL_GPL(edac_debugfs_create_dir_at);
101 * Create a file under EDAC's hierarchy or a sub-hierarchy:
103 * @name: file name
104 * @mode: file permissions
105 * @parent: parent dentry. If NULL, it becomes the toplevel EDAC dir
106 * @data: private data of caller
107 * @fops: file operations of this file
109 struct dentry *
110 edac_debugfs_create_file(const char *name, umode_t mode, struct dentry *parent,
111 void *data, const struct file_operations *fops)
113 if (!parent)
114 parent = edac_debugfs;
116 return debugfs_create_file(name, mode, parent, data, fops);
118 EXPORT_SYMBOL_GPL(edac_debugfs_create_file);
120 /* Wrapper for debugfs_create_x8() */
121 struct dentry *edac_debugfs_create_x8(const char *name, umode_t mode,
122 struct dentry *parent, u8 *value)
124 if (!parent)
125 parent = edac_debugfs;
127 return debugfs_create_x8(name, mode, parent, value);
129 EXPORT_SYMBOL_GPL(edac_debugfs_create_x8);
131 /* Wrapper for debugfs_create_x16() */
132 struct dentry *edac_debugfs_create_x16(const char *name, umode_t mode,
133 struct dentry *parent, u16 *value)
135 if (!parent)
136 parent = edac_debugfs;
138 return debugfs_create_x16(name, mode, parent, value);
140 EXPORT_SYMBOL_GPL(edac_debugfs_create_x16);