x86/boot: Rename overlapping memcpy() to memmove()
[linux/fpc-iii.git] / drivers / edac / debugfs.c
blob92dbb7e2320c78fe8cfc69fa80078de5b7b7f682
1 #include "edac_module.h"
3 static struct dentry *edac_debugfs;
5 static ssize_t edac_fake_inject_write(struct file *file,
6 const char __user *data,
7 size_t count, loff_t *ppos)
9 struct device *dev = file->private_data;
10 struct mem_ctl_info *mci = to_mci(dev);
11 static enum hw_event_mc_err_type type;
12 u16 errcount = mci->fake_inject_count;
14 if (!errcount)
15 errcount = 1;
17 type = mci->fake_inject_ue ? HW_EVENT_ERR_UNCORRECTED
18 : HW_EVENT_ERR_CORRECTED;
20 printk(KERN_DEBUG
21 "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",
22 errcount,
23 (type == HW_EVENT_ERR_UNCORRECTED) ? "UE" : "CE",
24 errcount > 1 ? "s" : "",
25 mci->fake_inject_layer[0],
26 mci->fake_inject_layer[1],
27 mci->fake_inject_layer[2]
29 edac_mc_handle_error(type, mci, errcount, 0, 0, 0,
30 mci->fake_inject_layer[0],
31 mci->fake_inject_layer[1],
32 mci->fake_inject_layer[2],
33 "FAKE ERROR", "for EDAC testing only");
35 return count;
38 static const struct file_operations debug_fake_inject_fops = {
39 .open = simple_open,
40 .write = edac_fake_inject_write,
41 .llseek = generic_file_llseek,
44 int __init edac_debugfs_init(void)
46 edac_debugfs = debugfs_create_dir("edac", NULL);
47 if (IS_ERR(edac_debugfs)) {
48 edac_debugfs = NULL;
49 return -ENOMEM;
51 return 0;
54 void edac_debugfs_exit(void)
56 debugfs_remove_recursive(edac_debugfs);
59 int edac_create_debugfs_nodes(struct mem_ctl_info *mci)
61 struct dentry *d, *parent;
62 char name[80];
63 int i;
65 if (!edac_debugfs)
66 return -ENODEV;
68 d = debugfs_create_dir(mci->dev.kobj.name, edac_debugfs);
69 if (!d)
70 return -ENOMEM;
71 parent = d;
73 for (i = 0; i < mci->n_layers; i++) {
74 sprintf(name, "fake_inject_%s",
75 edac_layer_name[mci->layers[i].type]);
76 d = debugfs_create_u8(name, S_IRUGO | S_IWUSR, parent,
77 &mci->fake_inject_layer[i]);
78 if (!d)
79 goto nomem;
82 d = debugfs_create_bool("fake_inject_ue", S_IRUGO | S_IWUSR, parent,
83 &mci->fake_inject_ue);
84 if (!d)
85 goto nomem;
87 d = debugfs_create_u16("fake_inject_count", S_IRUGO | S_IWUSR, parent,
88 &mci->fake_inject_count);
89 if (!d)
90 goto nomem;
92 d = debugfs_create_file("fake_inject", S_IWUSR, parent,
93 &mci->dev,
94 &debug_fake_inject_fops);
95 if (!d)
96 goto nomem;
98 mci->debugfs = parent;
99 return 0;
100 nomem:
101 edac_debugfs_remove_recursive(mci->debugfs);
102 return -ENOMEM;
105 /* Create a toplevel dir under EDAC's debugfs hierarchy */
106 struct dentry *edac_debugfs_create_dir(const char *dirname)
108 if (!edac_debugfs)
109 return NULL;
111 return debugfs_create_dir(dirname, edac_debugfs);
113 EXPORT_SYMBOL_GPL(edac_debugfs_create_dir);
115 /* Create a toplevel dir under EDAC's debugfs hierarchy with parent @parent */
116 struct dentry *
117 edac_debugfs_create_dir_at(const char *dirname, struct dentry *parent)
119 return debugfs_create_dir(dirname, parent);
121 EXPORT_SYMBOL_GPL(edac_debugfs_create_dir_at);
124 * Create a file under EDAC's hierarchy or a sub-hierarchy:
126 * @name: file name
127 * @mode: file permissions
128 * @parent: parent dentry. If NULL, it becomes the toplevel EDAC dir
129 * @data: private data of caller
130 * @fops: file operations of this file
132 struct dentry *
133 edac_debugfs_create_file(const char *name, umode_t mode, struct dentry *parent,
134 void *data, const struct file_operations *fops)
136 if (!parent)
137 parent = edac_debugfs;
139 return debugfs_create_file(name, mode, parent, data, fops);
141 EXPORT_SYMBOL_GPL(edac_debugfs_create_file);
143 /* Wrapper for debugfs_create_x8() */
144 struct dentry *edac_debugfs_create_x8(const char *name, umode_t mode,
145 struct dentry *parent, u8 *value)
147 if (!parent)
148 parent = edac_debugfs;
150 return debugfs_create_x8(name, mode, parent, value);
152 EXPORT_SYMBOL_GPL(edac_debugfs_create_x8);
154 /* Wrapper for debugfs_create_x16() */
155 struct dentry *edac_debugfs_create_x16(const char *name, umode_t mode,
156 struct dentry *parent, u16 *value)
158 if (!parent)
159 parent = edac_debugfs;
161 return debugfs_create_x16(name, mode, parent, value);
163 EXPORT_SYMBOL_GPL(edac_debugfs_create_x16);