EDAC, amd64: Move global code out of instance functions
authorYazen Ghannam <Yazen.Ghannam@amd.com>
Tue, 24 Jan 2017 22:32:25 +0000 (16:32 -0600)
committerBorislav Petkov <bp@suse.de>
Sat, 28 Jan 2017 12:08:10 +0000 (13:08 +0100)
We have a few functions that register/unregister an ECC error decoding
routine. These functions are called when we init/remove instances.
However, they are global and so don't need to be registered/unregistered
multiple times.

So move them out of the init/remove instance functions and into the
module init/exit routines.

Signed-off-by: Yazen Ghannam <Yazen.Ghannam@amd.com>
Cc: linux-edac <linux-edac@vger.kernel.org>
Link: http://lkml.kernel.org/r/1485297149-13733-4-git-send-email-Yazen.Ghannam@amd.com
Signed-off-by: Borislav Petkov <bp@suse.de>
drivers/edac/amd64_edac.c

index 5fa6e5ea8be334f2b5fea142b648b8f392190fd7..95c6a14401031b37e886e37b3386cbb3767bb95b 100644 (file)
@@ -3300,15 +3300,6 @@ static int init_one_instance(unsigned int nid)
                goto err_add_mc;
        }
 
-       /* register stuff with EDAC MCE */
-       if (report_gart_errors)
-               amd_report_gart_errors(true);
-
-       if (pvt->umc)
-               amd_register_ecc_decoder(decode_umc_error);
-       else
-               amd_register_ecc_decoder(decode_bus_error);
-
        return 0;
 
 err_add_mc:
@@ -3398,14 +3389,6 @@ static void remove_one_instance(unsigned int nid)
 
        free_mc_sibling_devs(pvt);
 
-       /* unregister from EDAC MCE */
-       amd_report_gart_errors(false);
-
-       if (pvt->umc)
-               amd_unregister_ecc_decoder(decode_umc_error);
-       else
-               amd_unregister_ecc_decoder(decode_bus_error);
-
        kfree(ecc_stngs[nid]);
        ecc_stngs[nid] = NULL;
 
@@ -3479,6 +3462,15 @@ static int __init amd64_edac_init(void)
                }
        }
 
+       /* register stuff with EDAC MCE */
+       if (report_gart_errors)
+               amd_report_gart_errors(true);
+
+       if (boot_cpu_data.x86 >= 0x17)
+               amd_register_ecc_decoder(decode_umc_error);
+       else
+               amd_register_ecc_decoder(decode_bus_error);
+
        setup_pci_device();
 
 #ifdef CONFIG_X86_32
@@ -3508,6 +3500,14 @@ static void __exit amd64_edac_exit(void)
        if (pci_ctl)
                edac_pci_release_generic_ctl(pci_ctl);
 
+       /* unregister from EDAC MCE */
+       amd_report_gart_errors(false);
+
+       if (boot_cpu_data.x86 >= 0x17)
+               amd_unregister_ecc_decoder(decode_umc_error);
+       else
+               amd_unregister_ecc_decoder(decode_bus_error);
+
        for (i = 0; i < amd_nb_num(); i++)
                remove_one_instance(i);