diff options
Diffstat (limited to 'drivers/edac/amd64_edac.c')
-rw-r--r-- | drivers/edac/amd64_edac.c | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c index 821bc2cdd2de..9905834b560f 100644 --- a/drivers/edac/amd64_edac.c +++ b/drivers/edac/amd64_edac.c | |||
@@ -2463,26 +2463,29 @@ static bool ecc_enabled(struct pci_dev *F3, u8 nid) | |||
2463 | return true; | 2463 | return true; |
2464 | } | 2464 | } |
2465 | 2465 | ||
2466 | struct mcidev_sysfs_attribute sysfs_attrs[ARRAY_SIZE(amd64_dbg_attrs) + | 2466 | static int set_mc_sysfs_attrs(struct mem_ctl_info *mci) |
2467 | ARRAY_SIZE(amd64_inj_attrs) + | ||
2468 | 1]; | ||
2469 | |||
2470 | struct mcidev_sysfs_attribute terminator = { .attr = { .name = NULL } }; | ||
2471 | |||
2472 | static void set_mc_sysfs_attrs(struct mem_ctl_info *mci) | ||
2473 | { | 2467 | { |
2474 | unsigned int i = 0, j = 0; | 2468 | int rc; |
2475 | 2469 | ||
2476 | for (; i < ARRAY_SIZE(amd64_dbg_attrs); i++) | 2470 | rc = amd64_create_sysfs_dbg_files(mci); |
2477 | sysfs_attrs[i] = amd64_dbg_attrs[i]; | 2471 | if (rc < 0) |
2472 | return rc; | ||
2478 | 2473 | ||
2479 | if (boot_cpu_data.x86 >= 0x10) | 2474 | if (boot_cpu_data.x86 >= 0x10) { |
2480 | for (j = 0; j < ARRAY_SIZE(amd64_inj_attrs); j++, i++) | 2475 | rc = amd64_create_sysfs_inject_files(mci); |
2481 | sysfs_attrs[i] = amd64_inj_attrs[j]; | 2476 | if (rc < 0) |
2477 | return rc; | ||
2478 | } | ||
2479 | |||
2480 | return 0; | ||
2481 | } | ||
2482 | 2482 | ||
2483 | sysfs_attrs[i] = terminator; | 2483 | static void del_mc_sysfs_attrs(struct mem_ctl_info *mci) |
2484 | { | ||
2485 | amd64_remove_sysfs_dbg_files(mci); | ||
2484 | 2486 | ||
2485 | mci->mc_driver_sysfs_attributes = sysfs_attrs; | 2487 | if (boot_cpu_data.x86 >= 0x10) |
2488 | amd64_remove_sysfs_inject_files(mci); | ||
2486 | } | 2489 | } |
2487 | 2490 | ||
2488 | static void setup_mci_misc_attrs(struct mem_ctl_info *mci, | 2491 | static void setup_mci_misc_attrs(struct mem_ctl_info *mci, |
@@ -2608,13 +2611,15 @@ static int amd64_init_one_instance(struct pci_dev *F2) | |||
2608 | if (init_csrows(mci)) | 2611 | if (init_csrows(mci)) |
2609 | mci->edac_cap = EDAC_FLAG_NONE; | 2612 | mci->edac_cap = EDAC_FLAG_NONE; |
2610 | 2613 | ||
2611 | set_mc_sysfs_attrs(mci); | ||
2612 | |||
2613 | ret = -ENODEV; | 2614 | ret = -ENODEV; |
2614 | if (edac_mc_add_mc(mci)) { | 2615 | if (edac_mc_add_mc(mci)) { |
2615 | debugf1("failed edac_mc_add_mc()\n"); | 2616 | debugf1("failed edac_mc_add_mc()\n"); |
2616 | goto err_add_mc; | 2617 | goto err_add_mc; |
2617 | } | 2618 | } |
2619 | if (set_mc_sysfs_attrs(mci)) { | ||
2620 | debugf1("failed edac_mc_add_mc()\n"); | ||
2621 | goto err_add_sysfs; | ||
2622 | } | ||
2618 | 2623 | ||
2619 | /* register stuff with EDAC MCE */ | 2624 | /* register stuff with EDAC MCE */ |
2620 | if (report_gart_errors) | 2625 | if (report_gart_errors) |
@@ -2628,6 +2633,8 @@ static int amd64_init_one_instance(struct pci_dev *F2) | |||
2628 | 2633 | ||
2629 | return 0; | 2634 | return 0; |
2630 | 2635 | ||
2636 | err_add_sysfs: | ||
2637 | edac_mc_del_mc(mci->pdev); | ||
2631 | err_add_mc: | 2638 | err_add_mc: |
2632 | edac_mc_free(mci); | 2639 | edac_mc_free(mci); |
2633 | 2640 | ||
@@ -2698,6 +2705,8 @@ static void __devexit amd64_remove_one_instance(struct pci_dev *pdev) | |||
2698 | struct pci_dev *F3 = node_to_amd_nb(nid)->misc; | 2705 | struct pci_dev *F3 = node_to_amd_nb(nid)->misc; |
2699 | struct ecc_settings *s = ecc_stngs[nid]; | 2706 | struct ecc_settings *s = ecc_stngs[nid]; |
2700 | 2707 | ||
2708 | mci = find_mci_by_dev(&pdev->dev); | ||
2709 | del_mc_sysfs_attrs(mci); | ||
2701 | /* Remove from EDAC CORE tracking list */ | 2710 | /* Remove from EDAC CORE tracking list */ |
2702 | mci = edac_mc_del_mc(&pdev->dev); | 2711 | mci = edac_mc_del_mc(&pdev->dev); |
2703 | if (!mci) | 2712 | if (!mci) |