]> err.no Git - linux-2.6/blobdiff - drivers/edac/i82875p_edac.c
[PATCH] EDAC: edac_mc_add_mc fix [2/2]
[linux-2.6] / drivers / edac / i82875p_edac.c
index 1991f94af7538d568bffd7ecc2faf7aa8e4fac43..40ba2be6169af526f3b0900f083b31ddd84c280d 100644 (file)
 #include "edac_mc.h"
 
 
+#define i82875p_printk(level, fmt, arg...) \
+    edac_printk(level, "i82875p", fmt, ##arg)
+
+
+#define i82875p_mc_printk(mci, level, fmt, arg...) \
+    edac_mc_chipset_printk(mci, level, "i82875p", fmt, ##arg)
+
+
 #ifndef PCI_DEVICE_ID_INTEL_82875_0
 #define PCI_DEVICE_ID_INTEL_82875_0    0x2578
 #endif                         /* PCI_DEVICE_ID_INTEL_82875_0 */
@@ -254,7 +262,7 @@ static void i82875p_check(struct mem_ctl_info *mci)
 {
        struct i82875p_error_info info;
 
-       debugf1("MC%d: " __FILE__ ": %s()\n", mci->mc_idx, __func__);
+       debugf1("MC%d: %s()\n", mci->mc_idx, __func__);
        i82875p_get_error_info(mci, &info);
        i82875p_process_error_info(mci, &info, 1);
 }
@@ -278,10 +286,11 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
        u32 drc_chan;           /* Number of channels 0=1chan,1=2chan */
        u32 nr_chans;
        u32 drc_ddim;           /* DRAM Data Integrity Mode 0=none,2=edac */
+       struct i82875p_error_info discard;
 
-       debugf0("MC: " __FILE__ ": %s()\n", __func__);
+       debugf0("%s()\n", __func__);
 
-       ovrfl_pdev = pci_find_device(PCI_VEND_DEV(INTEL, 82875_6), NULL);
+       ovrfl_pdev = pci_get_device(PCI_VEND_DEV(INTEL, 82875_6), NULL);
 
        if (!ovrfl_pdev) {
                /*
@@ -294,26 +303,26 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
                ovrfl_pdev =
                    pci_scan_single_device(pdev->bus, PCI_DEVFN(6, 0));
                if (!ovrfl_pdev)
-                       goto fail;
+                       return -ENODEV;
        }
 #ifdef CONFIG_PROC_FS
        if (!ovrfl_pdev->procent && pci_proc_attach_device(ovrfl_pdev)) {
-               printk(KERN_ERR "MC: " __FILE__
-                      ": %s(): Failed to attach overflow device\n",
-                      __func__);
-               goto fail;
+               i82875p_printk(KERN_ERR,
+                              "%s(): Failed to attach overflow device\n",
+                              __func__);
+               return -ENODEV;
        }
 #endif                         /* CONFIG_PROC_FS */
        if (pci_enable_device(ovrfl_pdev)) {
-               printk(KERN_ERR "MC: " __FILE__
-                      ": %s(): Failed to enable overflow device\n",
-                      __func__);
-               goto fail;
+               i82875p_printk(KERN_ERR,
+                              "%s(): Failed to enable overflow device\n",
+                              __func__);
+               return -ENODEV;
        }
 
        if (pci_request_regions(ovrfl_pdev, pci_name(ovrfl_pdev))) {
 #ifdef CORRECT_BIOS
-               goto fail;
+               goto fail0;
 #endif
        }
        /* cache is irrelevant for PCI bus reads/writes */
@@ -321,9 +330,9 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
                                       pci_resource_len(ovrfl_pdev, 0));
 
        if (!ovrfl_window) {
-               printk(KERN_ERR "MC: " __FILE__
-                      ": %s(): Failed to ioremap bar6\n", __func__);
-               goto fail;
+               i82875p_printk(KERN_ERR, "%s(): Failed to ioremap bar6\n",
+                              __func__);
+               goto fail1;
        }
 
        /* need to find out the number of channels */
@@ -337,10 +346,10 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
 
        if (!mci) {
                rc = -ENOMEM;
-               goto fail;
+               goto fail2;
        }
 
-       debugf3("MC: " __FILE__ ": %s(): init mci\n", __func__);
+       debugf3("%s(): init mci\n", __func__);
 
        mci->pdev = pdev;
        mci->mtype_cap = MEM_FLAG_DDR;
@@ -349,13 +358,13 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
        mci->edac_cap = EDAC_FLAG_UNKNOWN;
        /* adjust FLAGS */
 
-       mci->mod_name = BS_MOD_STR;
+       mci->mod_name = EDAC_MOD_STR;
        mci->mod_ver = "$Revision: 1.5.2.11 $";
        mci->ctl_name = i82875p_devs[dev_idx].ctl_name;
        mci->edac_check = i82875p_check;
        mci->ctl_page_to_phys = NULL;
 
-       debugf3("MC: " __FILE__ ": %s(): init pvt\n", __func__);
+       debugf3("%s(): init pvt\n", __func__);
 
        pvt = (struct i82875p_pvt *) mci->pvt_info;
        pvt->ovrfl_pdev = ovrfl_pdev;
@@ -374,8 +383,8 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
 
                value = readb(ovrfl_window + I82875P_DRB + index);
                cumul_size = value << (I82875P_DRB_SHIFT - PAGE_SHIFT);
-               debugf3("MC: " __FILE__ ": %s(): (%d) cumul_size 0x%x\n",
-                       __func__, index, cumul_size);
+               debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index,
+                       cumul_size);
                if (cumul_size == last_cumul_size)
                        continue;       /* not populated */
 
@@ -389,31 +398,30 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
                csrow->edac_mode = drc_ddim ? EDAC_SECDED : EDAC_NONE;
        }
 
-       /* clear counters */
-       pci_write_bits16(mci->pdev, I82875P_ERRSTS, 0x0081, 0x0081);
+       i82875p_get_error_info(mci, &discard);  /* clear counters */
 
        if (edac_mc_add_mc(mci)) {
-               debugf3("MC: " __FILE__
-                       ": %s(): failed edac_mc_add_mc()\n", __func__);
-               goto fail;
+               debugf3("%s(): failed edac_mc_add_mc()\n", __func__);
+               goto fail3;
        }
 
        /* get this far and it's successful */
-       debugf3("MC: " __FILE__ ": %s(): success\n", __func__);
+       debugf3("%s(): success\n", __func__);
        return 0;
 
-      fail:
-       if (mci)
-               edac_mc_free(mci);
+fail3:
+       edac_mc_free(mci);
 
-       if (ovrfl_window)
-               iounmap(ovrfl_window);
+fail2:
+       iounmap(ovrfl_window);
 
-       if (ovrfl_pdev) {
-               pci_release_regions(ovrfl_pdev);
-               pci_disable_device(ovrfl_pdev);
-       }
+fail1:
+       pci_release_regions(ovrfl_pdev);
 
+#ifdef CORRECT_BIOS
+fail0:
+#endif
+       pci_disable_device(ovrfl_pdev);
        /* NOTE: the ovrfl proc entry and pci_dev are intentionally left */
        return rc;
 }
@@ -425,9 +433,9 @@ static int __devinit i82875p_init_one(struct pci_dev *pdev,
 {
        int rc;
 
-       debugf0("MC: " __FILE__ ": %s()\n", __func__);
+       debugf0("%s()\n", __func__);
 
-       printk(KERN_INFO "i82875p init one\n");
+       i82875p_printk(KERN_INFO, "i82875p init one\n");
        if(pci_enable_device(pdev) < 0)
                return -EIO;
        rc = i82875p_probe1(pdev, ent->driver_data);
@@ -442,7 +450,7 @@ static void __devexit i82875p_remove_one(struct pci_dev *pdev)
        struct mem_ctl_info *mci;
        struct i82875p_pvt *pvt = NULL;
 
-       debugf0(__FILE__ ": %s()\n", __func__);
+       debugf0("%s()\n", __func__);
 
        if ((mci = edac_mc_find_mci_by_pdev(pdev)) == NULL)
                return;
@@ -476,7 +484,7 @@ MODULE_DEVICE_TABLE(pci, i82875p_pci_tbl);
 
 
 static struct pci_driver i82875p_driver = {
-       .name = BS_MOD_STR,
+       .name = EDAC_MOD_STR,
        .probe = i82875p_init_one,
        .remove = __devexit_p(i82875p_remove_one),
        .id_table = i82875p_pci_tbl,
@@ -487,33 +495,42 @@ static int __init i82875p_init(void)
 {
        int pci_rc;
 
-       debugf3("MC: " __FILE__ ": %s()\n", __func__);
+       debugf3("%s()\n", __func__);
        pci_rc = pci_register_driver(&i82875p_driver);
        if (pci_rc < 0)
-               return pci_rc;
+               goto fail0;
        if (mci_pdev == NULL) {
-               i82875p_registered = 0;
                mci_pdev =
                    pci_get_device(PCI_VENDOR_ID_INTEL,
                                   PCI_DEVICE_ID_INTEL_82875_0, NULL);
                if (!mci_pdev) {
                        debugf0("875p pci_get_device fail\n");
-                       return -ENODEV;
+                       pci_rc = -ENODEV;
+                       goto fail1;
                }
                pci_rc = i82875p_init_one(mci_pdev, i82875p_pci_tbl);
                if (pci_rc < 0) {
                        debugf0("875p init fail\n");
-                       pci_dev_put(mci_pdev);
-                       return -ENODEV;
+                       pci_rc = -ENODEV;
+                       goto fail1;
                }
        }
        return 0;
+
+fail1:
+       pci_unregister_driver(&i82875p_driver);
+
+fail0:
+       if (mci_pdev != NULL)
+               pci_dev_put(mci_pdev);
+
+       return pci_rc;
 }
 
 
 static void __exit i82875p_exit(void)
 {
-       debugf3("MC: " __FILE__ ": %s()\n", __func__);
+       debugf3("%s()\n", __func__);
 
        pci_unregister_driver(&i82875p_driver);
        if (!i82875p_registered) {