diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-08-10 17:57:01 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-10-24 09:20:14 -0400 |
commit | 1288c18f48d9bf373dbed6b688cde36dc970b1ed (patch) | |
tree | 34c00383b8e6beee2651b6b5614875d503cd7939 /drivers/edac/i7core_edac.c | |
parent | 18c29002f95bc2f67c1c78d7fc7932843aa66657 (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.c | 117 |
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 | ||
219 | struct pci_id_table { | 219 | struct 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 | ||
224 | struct i7core_dev { | 224 | struct 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 | ||
279 | struct pci_id_descr pci_dev_descr_i7core_nehalem[] = { | 279 | static 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 | ||
316 | struct pci_id_descr pci_dev_descr_lynnfield[] = { | 316 | static 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 | ||
338 | struct pci_id_descr pci_dev_descr_i7core_westmere[] = { | 338 | static 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) } |
370 | struct pci_id_table pci_dev_table[] = { | 370 | static 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 | */ |
489 | static int i7core_get_active_channels(u8 socket, unsigned *channels, | 489 | static 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 | ||
550 | static int get_dimm_config(struct mem_ctl_info *mci, int *csrow) | 550 | static 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 | */ |
741 | static int disable_inject(struct mem_ctl_info *mci) | 741 | static 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); | |||
923 | DECLARE_ADDR_MATCH(page, 0x10000); | 923 | DECLARE_ADDR_MATCH(page, 0x10000); |
924 | DECLARE_ADDR_MATCH(col, 0x4000); | 924 | DECLARE_ADDR_MATCH(col, 0x4000); |
925 | 925 | ||
926 | static int write_and_test(struct pci_dev *dev, int where, u32 val) | 926 | static 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 | 1125 | static const struct mcidev_sysfs_attribute i7core_addrmatch_attrs[] = { | |
1126 | static 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 | ||
1136 | static struct mcidev_sysfs_group i7core_inject_addrmatch = { | 1135 | static 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 | ||
1141 | static struct mcidev_sysfs_attribute i7core_udimm_counters_attrs[] = { | 1140 | static 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 | ||
1148 | static struct mcidev_sysfs_group i7core_udimm_counters = { | 1147 | static 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 | ||
1153 | static struct mcidev_sysfs_attribute i7core_sysfs_attrs[] = { | 1152 | static 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 | |||
1187 | static 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 | ||
1224 | static void __init i7core_xeon_pci_fixup(struct pci_id_table *table) | 1259 | static 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 | */ |
1267 | int i7core_get_onedevice(struct pci_dev **prev, int devno, | 1302 | int 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 | ||
1378 | static int i7core_get_devices(struct pci_id_table *table) | 1414 | static 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 | ||
1464 | error: | 1491 | error: |
@@ -1472,7 +1499,9 @@ error: | |||
1472 | Error check routines | 1499 | Error check routines |
1473 | ****************************************************************************/ | 1500 | ****************************************************************************/ |
1474 | static void i7core_rdimm_update_csrow(struct mem_ctl_info *mci, | 1501 | static 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 | ||
1491 | static void i7core_rdimm_update_ce_count(struct mem_ctl_info *mci, | 1520 | static 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 | */ |
1645 | static void i7core_mce_output_error(struct mem_ctl_info *mci, | 1677 | static 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 | ||
1850 | static int i7core_register_mci(struct i7core_dev *i7core_dev, | 1882 | static 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 | ||