aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/edac/i7core_edac.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2010-08-10 17:57:01 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-10-24 09:20:14 -0400
commit1288c18f48d9bf373dbed6b688cde36dc970b1ed (patch)
tree34c00383b8e6beee2651b6b5614875d503cd7939 /drivers/edac/i7core_edac.c
parent18c29002f95bc2f67c1c78d7fc7932843aa66657 (diff)
i7core_edac: Properly mark const static vars as such
There are two groups of sysfs attributes: one for rdimm and another for udimm. Instead of changing dynamically the unique static struct for handling udimm's, declare two vars and make them constant. This avoids the risk of having two or more memory controllers, each needing a different set of attributes. While here, use const on all places where it is applicable. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com> edac_core: use const for constant sysfs arguments Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/edac/i7core_edac.c')
-rw-r--r--drivers/edac/i7core_edac.c117
1 files changed, 77 insertions, 40 deletions
diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
index 4c1dcc1f562e..5d15daaec8b8 100644
--- a/drivers/edac/i7core_edac.c
+++ b/drivers/edac/i7core_edac.c
@@ -217,8 +217,8 @@ struct pci_id_descr {
217}; 217};
218 218
219struct pci_id_table { 219struct pci_id_table {
220 struct pci_id_descr *descr; 220 const struct pci_id_descr *descr;
221 int n_devs; 221 int n_devs;
222}; 222};
223 223
224struct i7core_dev { 224struct i7core_dev {
@@ -276,7 +276,7 @@ struct i7core_pvt {
276 .func = (function), \ 276 .func = (function), \
277 .dev_id = (device_id) 277 .dev_id = (device_id)
278 278
279struct pci_id_descr pci_dev_descr_i7core_nehalem[] = { 279static const struct pci_id_descr pci_dev_descr_i7core_nehalem[] = {
280 /* Memory controller */ 280 /* Memory controller */
281 { PCI_DESCR(3, 0, PCI_DEVICE_ID_INTEL_I7_MCR) }, 281 { PCI_DESCR(3, 0, PCI_DEVICE_ID_INTEL_I7_MCR) },
282 { PCI_DESCR(3, 1, PCI_DEVICE_ID_INTEL_I7_MC_TAD) }, 282 { PCI_DESCR(3, 1, PCI_DEVICE_ID_INTEL_I7_MC_TAD) },
@@ -313,7 +313,7 @@ struct pci_id_descr pci_dev_descr_i7core_nehalem[] = {
313 313
314}; 314};
315 315
316struct pci_id_descr pci_dev_descr_lynnfield[] = { 316static const struct pci_id_descr pci_dev_descr_lynnfield[] = {
317 { PCI_DESCR( 3, 0, PCI_DEVICE_ID_INTEL_LYNNFIELD_MCR) }, 317 { PCI_DESCR( 3, 0, PCI_DEVICE_ID_INTEL_LYNNFIELD_MCR) },
318 { PCI_DESCR( 3, 1, PCI_DEVICE_ID_INTEL_LYNNFIELD_MC_TAD) }, 318 { PCI_DESCR( 3, 1, PCI_DEVICE_ID_INTEL_LYNNFIELD_MC_TAD) },
319 { PCI_DESCR( 3, 4, PCI_DEVICE_ID_INTEL_LYNNFIELD_MC_TEST) }, 319 { PCI_DESCR( 3, 4, PCI_DEVICE_ID_INTEL_LYNNFIELD_MC_TEST) },
@@ -335,7 +335,7 @@ struct pci_id_descr pci_dev_descr_lynnfield[] = {
335 { PCI_DESCR( 0, 0, PCI_DEVICE_ID_INTEL_LYNNFIELD_NONCORE) }, 335 { PCI_DESCR( 0, 0, PCI_DEVICE_ID_INTEL_LYNNFIELD_NONCORE) },
336}; 336};
337 337
338struct pci_id_descr pci_dev_descr_i7core_westmere[] = { 338static const struct pci_id_descr pci_dev_descr_i7core_westmere[] = {
339 /* Memory controller */ 339 /* Memory controller */
340 { PCI_DESCR(3, 0, PCI_DEVICE_ID_INTEL_LYNNFIELD_MCR_REV2) }, 340 { PCI_DESCR(3, 0, PCI_DEVICE_ID_INTEL_LYNNFIELD_MCR_REV2) },
341 { PCI_DESCR(3, 1, PCI_DEVICE_ID_INTEL_LYNNFIELD_MC_TAD_REV2) }, 341 { PCI_DESCR(3, 1, PCI_DEVICE_ID_INTEL_LYNNFIELD_MC_TAD_REV2) },
@@ -366,8 +366,8 @@ struct pci_id_descr pci_dev_descr_i7core_westmere[] = {
366 366
367}; 367};
368 368
369#define PCI_ID_TABLE_ENTRY(A) { A, ARRAY_SIZE(A) } 369#define PCI_ID_TABLE_ENTRY(A) { .descr=A, .n_devs = ARRAY_SIZE(A) }
370struct pci_id_table pci_dev_table[] = { 370static const struct pci_id_table pci_dev_table[] = {
371 PCI_ID_TABLE_ENTRY(pci_dev_descr_i7core_nehalem), 371 PCI_ID_TABLE_ENTRY(pci_dev_descr_i7core_nehalem),
372 PCI_ID_TABLE_ENTRY(pci_dev_descr_lynnfield), 372 PCI_ID_TABLE_ENTRY(pci_dev_descr_lynnfield),
373 PCI_ID_TABLE_ENTRY(pci_dev_descr_i7core_westmere), 373 PCI_ID_TABLE_ENTRY(pci_dev_descr_i7core_westmere),
@@ -486,7 +486,7 @@ static struct pci_dev *get_pdev_slot_func(u8 socket, unsigned slot,
486 * to add a fake description for csrows. 486 * to add a fake description for csrows.
487 * So, this driver is attributing one DIMM memory for one csrow. 487 * So, this driver is attributing one DIMM memory for one csrow.
488 */ 488 */
489static int i7core_get_active_channels(u8 socket, unsigned *channels, 489static int i7core_get_active_channels(const u8 socket, unsigned *channels,
490 unsigned *csrows) 490 unsigned *csrows)
491{ 491{
492 struct pci_dev *pdev = NULL; 492 struct pci_dev *pdev = NULL;
@@ -547,7 +547,7 @@ static int i7core_get_active_channels(u8 socket, unsigned *channels,
547 return 0; 547 return 0;
548} 548}
549 549
550static int get_dimm_config(struct mem_ctl_info *mci, int *csrow) 550static int get_dimm_config(const struct mem_ctl_info *mci, int *csrow)
551{ 551{
552 struct i7core_pvt *pvt = mci->pvt_info; 552 struct i7core_pvt *pvt = mci->pvt_info;
553 struct csrow_info *csr; 553 struct csrow_info *csr;
@@ -738,7 +738,7 @@ static int get_dimm_config(struct mem_ctl_info *mci, int *csrow)
738 we're disabling error injection on all write calls to the sysfs nodes that 738 we're disabling error injection on all write calls to the sysfs nodes that
739 controls the error code injection. 739 controls the error code injection.
740 */ 740 */
741static int disable_inject(struct mem_ctl_info *mci) 741static int disable_inject(const struct mem_ctl_info *mci)
742{ 742{
743 struct i7core_pvt *pvt = mci->pvt_info; 743 struct i7core_pvt *pvt = mci->pvt_info;
744 744
@@ -923,7 +923,7 @@ DECLARE_ADDR_MATCH(bank, 32);
923DECLARE_ADDR_MATCH(page, 0x10000); 923DECLARE_ADDR_MATCH(page, 0x10000);
924DECLARE_ADDR_MATCH(col, 0x4000); 924DECLARE_ADDR_MATCH(col, 0x4000);
925 925
926static int write_and_test(struct pci_dev *dev, int where, u32 val) 926static int write_and_test(struct pci_dev *dev, const int where, const u32 val)
927{ 927{
928 u32 read; 928 u32 read;
929 int count; 929 int count;
@@ -1122,35 +1122,34 @@ DECLARE_COUNTER(2);
1122 * Sysfs struct 1122 * Sysfs struct
1123 */ 1123 */
1124 1124
1125 1125static const struct mcidev_sysfs_attribute i7core_addrmatch_attrs[] = {
1126static struct mcidev_sysfs_attribute i7core_addrmatch_attrs[] = {
1127 ATTR_ADDR_MATCH(channel), 1126 ATTR_ADDR_MATCH(channel),
1128 ATTR_ADDR_MATCH(dimm), 1127 ATTR_ADDR_MATCH(dimm),
1129 ATTR_ADDR_MATCH(rank), 1128 ATTR_ADDR_MATCH(rank),
1130 ATTR_ADDR_MATCH(bank), 1129 ATTR_ADDR_MATCH(bank),
1131 ATTR_ADDR_MATCH(page), 1130 ATTR_ADDR_MATCH(page),
1132 ATTR_ADDR_MATCH(col), 1131 ATTR_ADDR_MATCH(col),
1133 { .attr = { .name = NULL } } 1132 { } /* End of list */
1134}; 1133};
1135 1134
1136static struct mcidev_sysfs_group i7core_inject_addrmatch = { 1135static const struct mcidev_sysfs_group i7core_inject_addrmatch = {
1137 .name = "inject_addrmatch", 1136 .name = "inject_addrmatch",
1138 .mcidev_attr = i7core_addrmatch_attrs, 1137 .mcidev_attr = i7core_addrmatch_attrs,
1139}; 1138};
1140 1139
1141static struct mcidev_sysfs_attribute i7core_udimm_counters_attrs[] = { 1140static const struct mcidev_sysfs_attribute i7core_udimm_counters_attrs[] = {
1142 ATTR_COUNTER(0), 1141 ATTR_COUNTER(0),
1143 ATTR_COUNTER(1), 1142 ATTR_COUNTER(1),
1144 ATTR_COUNTER(2), 1143 ATTR_COUNTER(2),
1145 { .attr = { .name = NULL } } 1144 { .attr = { .name = NULL } }
1146}; 1145};
1147 1146
1148static struct mcidev_sysfs_group i7core_udimm_counters = { 1147static const struct mcidev_sysfs_group i7core_udimm_counters = {
1149 .name = "all_channel_counts", 1148 .name = "all_channel_counts",
1150 .mcidev_attr = i7core_udimm_counters_attrs, 1149 .mcidev_attr = i7core_udimm_counters_attrs,
1151}; 1150};
1152 1151
1153static struct mcidev_sysfs_attribute i7core_sysfs_attrs[] = { 1152static const struct mcidev_sysfs_attribute i7core_sysfs_rdimm_attrs[] = {
1154 { 1153 {
1155 .attr = { 1154 .attr = {
1156 .name = "inject_section", 1155 .name = "inject_section",
@@ -1182,8 +1181,44 @@ static struct mcidev_sysfs_attribute i7core_sysfs_attrs[] = {
1182 .show = i7core_inject_enable_show, 1181 .show = i7core_inject_enable_show,
1183 .store = i7core_inject_enable_store, 1182 .store = i7core_inject_enable_store,
1184 }, 1183 },
1185 { .attr = { .name = NULL } }, /* Reserved for udimm counters */ 1184 { } /* End of list */
1186 { .attr = { .name = NULL } } 1185};
1186
1187static const struct mcidev_sysfs_attribute i7core_sysfs_udimm_attrs[] = {
1188 {
1189 .attr = {
1190 .name = "inject_section",
1191 .mode = (S_IRUGO | S_IWUSR)
1192 },
1193 .show = i7core_inject_section_show,
1194 .store = i7core_inject_section_store,
1195 }, {
1196 .attr = {
1197 .name = "inject_type",
1198 .mode = (S_IRUGO | S_IWUSR)
1199 },
1200 .show = i7core_inject_type_show,
1201 .store = i7core_inject_type_store,
1202 }, {
1203 .attr = {
1204 .name = "inject_eccmask",
1205 .mode = (S_IRUGO | S_IWUSR)
1206 },
1207 .show = i7core_inject_eccmask_show,
1208 .store = i7core_inject_eccmask_store,
1209 }, {
1210 .grp = &i7core_inject_addrmatch,
1211 }, {
1212 .attr = {
1213 .name = "inject_enable",
1214 .mode = (S_IRUGO | S_IWUSR)
1215 },
1216 .show = i7core_inject_enable_show,
1217 .store = i7core_inject_enable_store,
1218 }, {
1219 .grp = &i7core_udimm_counters,
1220 },
1221 { } /* End of list */
1187}; 1222};
1188 1223
1189/**************************************************************************** 1224/****************************************************************************
@@ -1221,7 +1256,7 @@ static void i7core_put_all_devices(void)
1221 i7core_put_devices(i7core_dev); 1256 i7core_put_devices(i7core_dev);
1222} 1257}
1223 1258
1224static void __init i7core_xeon_pci_fixup(struct pci_id_table *table) 1259static void __init i7core_xeon_pci_fixup(const struct pci_id_table *table)
1225{ 1260{
1226 struct pci_dev *pdev = NULL; 1261 struct pci_dev *pdev = NULL;
1227 int i; 1262 int i;
@@ -1264,9 +1299,10 @@ static unsigned i7core_pci_lastbus(void)
1264 * 1299 *
1265 * Need to 'get' device 16 func 1 and func 2 1300 * Need to 'get' device 16 func 1 and func 2
1266 */ 1301 */
1267int i7core_get_onedevice(struct pci_dev **prev, int devno, 1302int i7core_get_onedevice(struct pci_dev **prev, const int devno,
1268 struct pci_id_descr *dev_descr, unsigned n_devs, 1303 const struct pci_id_descr *dev_descr,
1269 unsigned last_bus) 1304 const unsigned n_devs,
1305 const unsigned last_bus)
1270{ 1306{
1271 struct i7core_dev *i7core_dev; 1307 struct i7core_dev *i7core_dev;
1272 1308
@@ -1375,11 +1411,11 @@ int i7core_get_onedevice(struct pci_dev **prev, int devno,
1375 return 0; 1411 return 0;
1376} 1412}
1377 1413
1378static int i7core_get_devices(struct pci_id_table *table) 1414static int i7core_get_devices(const struct pci_id_table *table)
1379{ 1415{
1380 int i, rc, last_bus; 1416 int i, rc, last_bus;
1381 struct pci_dev *pdev = NULL; 1417 struct pci_dev *pdev = NULL;
1382 struct pci_id_descr *dev_descr; 1418 const struct pci_id_descr *dev_descr;
1383 1419
1384 last_bus = i7core_pci_lastbus(); 1420 last_bus = i7core_pci_lastbus();
1385 1421
@@ -1450,15 +1486,6 @@ static int mci_bind_devs(struct mem_ctl_info *mci,
1450 pvt->is_registered = 1; 1486 pvt->is_registered = 1;
1451 } 1487 }
1452 1488
1453 /*
1454 * Add extra nodes to count errors on udimm
1455 * For registered memory, this is not needed, since the counters
1456 * are already displayed at the standard locations
1457 */
1458 if (!pvt->is_registered)
1459 i7core_sysfs_attrs[ARRAY_SIZE(i7core_sysfs_attrs)-2].grp =
1460 &i7core_udimm_counters;
1461
1462 return 0; 1489 return 0;
1463 1490
1464error: 1491error:
@@ -1472,7 +1499,9 @@ error:
1472 Error check routines 1499 Error check routines
1473 ****************************************************************************/ 1500 ****************************************************************************/
1474static void i7core_rdimm_update_csrow(struct mem_ctl_info *mci, 1501static void i7core_rdimm_update_csrow(struct mem_ctl_info *mci,
1475 int chan, int dimm, int add) 1502 const int chan,
1503 const int dimm,
1504 const int add)
1476{ 1505{
1477 char *msg; 1506 char *msg;
1478 struct i7core_pvt *pvt = mci->pvt_info; 1507 struct i7core_pvt *pvt = mci->pvt_info;
@@ -1489,7 +1518,10 @@ static void i7core_rdimm_update_csrow(struct mem_ctl_info *mci,
1489} 1518}
1490 1519
1491static void i7core_rdimm_update_ce_count(struct mem_ctl_info *mci, 1520static void i7core_rdimm_update_ce_count(struct mem_ctl_info *mci,
1492 int chan, int new0, int new1, int new2) 1521 const int chan,
1522 const int new0,
1523 const int new1,
1524 const int new2)
1493{ 1525{
1494 struct i7core_pvt *pvt = mci->pvt_info; 1526 struct i7core_pvt *pvt = mci->pvt_info;
1495 int add0 = 0, add1 = 0, add2 = 0; 1527 int add0 = 0, add1 = 0, add2 = 0;
@@ -1643,7 +1675,7 @@ static void i7core_udimm_check_mc_ecc_err(struct mem_ctl_info *mci)
1643 * fields 1675 * fields
1644 */ 1676 */
1645static void i7core_mce_output_error(struct mem_ctl_info *mci, 1677static void i7core_mce_output_error(struct mem_ctl_info *mci,
1646 struct mce *m) 1678 const struct mce *m)
1647{ 1679{
1648 struct i7core_pvt *pvt = mci->pvt_info; 1680 struct i7core_pvt *pvt = mci->pvt_info;
1649 char *type, *optype, *err, *msg; 1681 char *type, *optype, *err, *msg;
@@ -1848,7 +1880,7 @@ static int i7core_mce_check_error(void *priv, struct mce *mce)
1848} 1880}
1849 1881
1850static int i7core_register_mci(struct i7core_dev *i7core_dev, 1882static int i7core_register_mci(struct i7core_dev *i7core_dev,
1851 int num_channels, int num_csrows) 1883 const int num_channels, const int num_csrows)
1852{ 1884{
1853 struct mem_ctl_info *mci; 1885 struct mem_ctl_info *mci;
1854 struct i7core_pvt *pvt; 1886 struct i7core_pvt *pvt;
@@ -1883,7 +1915,12 @@ static int i7core_register_mci(struct i7core_dev *i7core_dev,
1883 i7core_dev->socket); 1915 i7core_dev->socket);
1884 mci->dev_name = pci_name(i7core_dev->pdev[0]); 1916 mci->dev_name = pci_name(i7core_dev->pdev[0]);
1885 mci->ctl_page_to_phys = NULL; 1917 mci->ctl_page_to_phys = NULL;
1886 mci->mc_driver_sysfs_attributes = i7core_sysfs_attrs; 1918
1919 if (pvt->is_registered)
1920 mci->mc_driver_sysfs_attributes = i7core_sysfs_rdimm_attrs;
1921 else
1922 mci->mc_driver_sysfs_attributes = i7core_sysfs_udimm_attrs;
1923
1887 /* Set the function pointer to an actual operation function */ 1924 /* Set the function pointer to an actual operation function */
1888 mci->edac_check = i7core_check_error; 1925 mci->edac_check = i7core_check_error;
1889 1926