aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/edac/i5100_edac.c71
1 files changed, 70 insertions, 1 deletions
diff --git a/drivers/edac/i5100_edac.c b/drivers/edac/i5100_edac.c
index 0a0345bd7432..ad4cc898dc60 100644
--- a/drivers/edac/i5100_edac.c
+++ b/drivers/edac/i5100_edac.c
@@ -27,6 +27,7 @@
27#include <linux/edac.h> 27#include <linux/edac.h>
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/mmzone.h> 29#include <linux/mmzone.h>
30#include <linux/debugfs.h>
30 31
31#include "edac_core.h" 32#include "edac_core.h"
32 33
@@ -360,8 +361,12 @@ struct i5100_priv {
360 u8 inject_deviceptr2; 361 u8 inject_deviceptr2;
361 u16 inject_eccmask1; 362 u16 inject_eccmask1;
362 u16 inject_eccmask2; 363 u16 inject_eccmask2;
364
365 struct dentry *debugfs;
363}; 366};
364 367
368static struct dentry *i5100_debugfs;
369
365/* map a rank/chan to a slot number on the mainboard */ 370/* map a rank/chan to a slot number on the mainboard */
366static int i5100_rank_to_slot(const struct mem_ctl_info *mci, 371static int i5100_rank_to_slot(const struct mem_ctl_info *mci,
367 int chan, int rank) 372 int chan, int rank)
@@ -944,6 +949,61 @@ static void i5100_do_inject(struct mem_ctl_info *mci)
944 pci_write_config_byte(priv->einj, I5100_DINJ0, 0xab); 949 pci_write_config_byte(priv->einj, I5100_DINJ0, 0xab);
945} 950}
946 951
952#define to_mci(k) container_of(k, struct mem_ctl_info, dev)
953static ssize_t inject_enable_write(struct file *file, const char __user *data,
954 size_t count, loff_t *ppos)
955{
956 struct device *dev = file->private_data;
957 struct mem_ctl_info *mci = to_mci(dev);
958
959 i5100_do_inject(mci);
960
961 return count;
962}
963
964static int inject_enable_open(struct inode *inode, struct file *file)
965{
966 file->private_data = inode->i_private;
967 return 0;
968}
969
970static const struct file_operations i5100_inject_enable_fops = {
971 .open = inject_enable_open,
972 .write = inject_enable_write,
973 .llseek = generic_file_llseek,
974};
975
976static int i5100_setup_debugfs(struct mem_ctl_info *mci)
977{
978 struct i5100_priv *priv = mci->pvt_info;
979
980 if (!i5100_debugfs)
981 return -ENODEV;
982
983 priv->debugfs = debugfs_create_dir(mci->bus.name, i5100_debugfs);
984
985 if (!priv->debugfs)
986 return -ENOMEM;
987
988 debugfs_create_x8("inject_channel", S_IRUGO | S_IWUSR, priv->debugfs,
989 &priv->inject_channel);
990 debugfs_create_x8("inject_hlinesel", S_IRUGO | S_IWUSR, priv->debugfs,
991 &priv->inject_hlinesel);
992 debugfs_create_x8("inject_deviceptr1", S_IRUGO | S_IWUSR, priv->debugfs,
993 &priv->inject_deviceptr1);
994 debugfs_create_x8("inject_deviceptr2", S_IRUGO | S_IWUSR, priv->debugfs,
995 &priv->inject_deviceptr2);
996 debugfs_create_x16("inject_eccmask1", S_IRUGO | S_IWUSR, priv->debugfs,
997 &priv->inject_eccmask1);
998 debugfs_create_x16("inject_eccmask2", S_IRUGO | S_IWUSR, priv->debugfs,
999 &priv->inject_eccmask2);
1000 debugfs_create_file("inject_enable", S_IWUSR, priv->debugfs,
1001 &mci->dev, &i5100_inject_enable_fops);
1002
1003 return 0;
1004
1005}
1006
947static int i5100_init_one(struct pci_dev *pdev, const struct pci_device_id *id) 1007static int i5100_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
948{ 1008{
949 int rc; 1009 int rc;
@@ -1097,6 +1157,8 @@ static int i5100_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
1097 goto bail_scrub; 1157 goto bail_scrub;
1098 } 1158 }
1099 1159
1160 i5100_setup_debugfs(mci);
1161
1100 return ret; 1162 return ret;
1101 1163
1102bail_scrub: 1164bail_scrub:
@@ -1141,6 +1203,9 @@ static void i5100_remove_one(struct pci_dev *pdev)
1141 1203
1142 priv = mci->pvt_info; 1204 priv = mci->pvt_info;
1143 1205
1206 if (priv->debugfs)
1207 debugfs_remove_recursive(priv->debugfs);
1208
1144 priv->scrub_enable = 0; 1209 priv->scrub_enable = 0;
1145 cancel_delayed_work_sync(&(priv->i5100_scrubbing)); 1210 cancel_delayed_work_sync(&(priv->i5100_scrubbing));
1146 1211
@@ -1173,13 +1238,17 @@ static int __init i5100_init(void)
1173{ 1238{
1174 int pci_rc; 1239 int pci_rc;
1175 1240
1176 pci_rc = pci_register_driver(&i5100_driver); 1241 i5100_debugfs = debugfs_create_dir("i5100_edac", NULL);
1177 1242
1243 pci_rc = pci_register_driver(&i5100_driver);
1178 return (pci_rc < 0) ? pci_rc : 0; 1244 return (pci_rc < 0) ? pci_rc : 0;
1179} 1245}
1180 1246
1181static void __exit i5100_exit(void) 1247static void __exit i5100_exit(void)
1182{ 1248{
1249 if (i5100_debugfs)
1250 debugfs_remove(i5100_debugfs);
1251
1183 pci_unregister_driver(&i5100_driver); 1252 pci_unregister_driver(&i5100_driver);
1184} 1253}
1185 1254