Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris...
[pandora-kernel.git] / drivers / edac / e7xxx_edac.c
index 2b20610..96ecc49 100644 (file)
@@ -144,19 +144,21 @@ struct e7xxx_error_info {
        u32 dram_uelog_add;
 };
 
+static struct edac_pci_ctl_info *e7xxx_pci;
+
 static const struct e7xxx_dev_info e7xxx_devs[] = {
        [E7500] = {
-                  .err_dev = PCI_DEVICE_ID_INTEL_7500_1_ERR,
-                  .ctl_name = "E7500"},
+               .err_dev = PCI_DEVICE_ID_INTEL_7500_1_ERR,
+               .ctl_name = "E7500"},
        [E7501] = {
-                  .err_dev = PCI_DEVICE_ID_INTEL_7501_1_ERR,
-                  .ctl_name = "E7501"},
+               .err_dev = PCI_DEVICE_ID_INTEL_7501_1_ERR,
+               .ctl_name = "E7501"},
        [E7505] = {
-                  .err_dev = PCI_DEVICE_ID_INTEL_7505_1_ERR,
-                  .ctl_name = "E7505"},
+               .err_dev = PCI_DEVICE_ID_INTEL_7505_1_ERR,
+               .ctl_name = "E7505"},
        [E7205] = {
-                  .err_dev = PCI_DEVICE_ID_INTEL_7205_1_ERR,
-                  .ctl_name = "E7205"},
+               .err_dev = PCI_DEVICE_ID_INTEL_7205_1_ERR,
+               .ctl_name = "E7205"},
 };
 
 /* FIXME - is this valid for both SECDED and S4ECD4ED? */
@@ -177,7 +179,7 @@ static inline int e7xxx_find_channel(u16 syndrome)
 }
 
 static unsigned long ctl_page_to_phys(struct mem_ctl_info *mci,
-                                     unsigned long page)
+                               unsigned long page)
 {
        u32 remap;
        struct e7xxx_pvt *pvt = (struct e7xxx_pvt *)mci->pvt_info;
@@ -185,7 +187,7 @@ static unsigned long ctl_page_to_phys(struct mem_ctl_info *mci,
        debugf3("%s()\n", __func__);
 
        if ((page < pvt->tolm) ||
-           ((page >= 0x100000) && (page < pvt->remapbase)))
+               ((page >= 0x100000) && (page < pvt->remapbase)))
                return page;
 
        remap = (page - pvt->tolm) + pvt->remapbase;
@@ -255,15 +257,15 @@ static void e7xxx_get_error_info(struct mem_ctl_info *mci,
 
        if ((info->dram_ferr & 1) || (info->dram_nerr & 1)) {
                pci_read_config_dword(pvt->bridge_ck, E7XXX_DRAM_CELOG_ADD,
-                                     &info->dram_celog_add);
+                               &info->dram_celog_add);
                pci_read_config_word(pvt->bridge_ck,
-                                    E7XXX_DRAM_CELOG_SYNDROME,
-                                    &info->dram_celog_syndrome);
+                               E7XXX_DRAM_CELOG_SYNDROME,
+                               &info->dram_celog_syndrome);
        }
 
        if ((info->dram_ferr & 2) || (info->dram_nerr & 2))
                pci_read_config_dword(pvt->bridge_ck, E7XXX_DRAM_UELOG_ADD,
-                                     &info->dram_uelog_add);
+                               &info->dram_uelog_add);
 
        if (info->dram_ferr & 3)
                pci_write_bits8(pvt->bridge_ck, E7XXX_DRAM_FERR, 0x03, 0x03);
@@ -273,8 +275,8 @@ static void e7xxx_get_error_info(struct mem_ctl_info *mci,
 }
 
 static int e7xxx_process_error_info(struct mem_ctl_info *mci,
-                                   struct e7xxx_error_info *info,
-                                   int handle_errors)
+                               struct e7xxx_error_info *info,
+                               int handle_errors)
 {
        int error_found;
 
@@ -343,7 +345,7 @@ static inline int drb_granularity(u32 drc, int dev_idx)
 }
 
 static void e7xxx_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev,
-                             int dev_idx, u32 drc)
+                       int dev_idx, u32 drc)
 {
        unsigned long last_cumul_size;
        int index;
@@ -425,7 +427,7 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
        pci_read_config_dword(pdev, E7XXX_DRC, &drc);
 
        drc_chan = dual_channel_active(drc, dev_idx);
-       mci = edac_mc_alloc(sizeof(*pvt), E7XXX_NR_CSROWS, drc_chan + 1);
+       mci = edac_mc_alloc(sizeof(*pvt), E7XXX_NR_CSROWS, drc_chan + 1, 0);
 
        if (mci == NULL)
                return -ENOMEM;
@@ -433,7 +435,7 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
        debugf3("%s(): init mci\n", __func__);
        mci->mtype_cap = MEM_FLAG_RDDR;
        mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED |
-           EDAC_FLAG_S4ECD4ED;
+               EDAC_FLAG_S4ECD4ED;
        /* FIXME - what if different memory types are in different csrows? */
        mci->mod_name = EDAC_MOD_STR;
        mci->mod_ver = E7XXX_REVISION;
@@ -446,8 +448,8 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
 
        if (!pvt->bridge_ck) {
                e7xxx_printk(KERN_ERR, "error reporting device not found:"
-                            "vendor %x device 0x%x (broken BIOS?)\n",
-                            PCI_VENDOR_ID_INTEL, e7xxx_devs[dev_idx].err_dev);
+                       "vendor %x device 0x%x (broken BIOS?)\n",
+                       PCI_VENDOR_ID_INTEL, e7xxx_devs[dev_idx].err_dev);
                goto fail0;
        }
 
@@ -467,8 +469,8 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
        pci_read_config_word(pdev, E7XXX_REMAPLIMIT, &pci_data);
        pvt->remaplimit = ((u32) pci_data) << 14;
        e7xxx_printk(KERN_INFO,
-                    "tolm = %x, remapbase = %x, remaplimit = %x\n", pvt->tolm,
-                    pvt->remapbase, pvt->remaplimit);
+               "tolm = %x, remapbase = %x, remaplimit = %x\n", pvt->tolm,
+               pvt->remapbase, pvt->remaplimit);
 
        /* clear any pending errors, or initial state bits */
        e7xxx_get_error_info(mci, &discard);
@@ -476,19 +478,30 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
        /* Here we assume that we will never see multiple instances of this
         * type of memory controller.  The ID is therefore hardcoded to 0.
         */
-       if (edac_mc_add_mc(mci, 0)) {
+       if (edac_mc_add_mc(mci)) {
                debugf3("%s(): failed edac_mc_add_mc()\n", __func__);
                goto fail1;
        }
 
+       /* allocating generic PCI control info */
+       e7xxx_pci = edac_pci_create_generic_ctl(&pdev->dev, EDAC_MOD_STR);
+       if (!e7xxx_pci) {
+               printk(KERN_WARNING
+                       "%s(): Unable to create PCI control\n",
+                       __func__);
+               printk(KERN_WARNING
+                       "%s(): PCI error report via EDAC not setup\n",
+                       __func__);
+       }
+
        /* get this far and it's successful */
        debugf3("%s(): success\n", __func__);
        return 0;
 
-      fail1:
+fail1:
        pci_dev_put(pvt->bridge_ck);
 
-      fail0:
+fail0:
        edac_mc_free(mci);
 
        return -ENODEV;
@@ -496,13 +509,13 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
 
 /* returns count (>= 0), or negative on error */
 static int __devinit e7xxx_init_one(struct pci_dev *pdev,
-                                   const struct pci_device_id *ent)
+                               const struct pci_device_id *ent)
 {
        debugf0("%s()\n", __func__);
 
        /* wake up and enable device */
        return pci_enable_device(pdev) ?
-           -EIO : e7xxx_probe1(pdev, ent->driver_data);
+               -EIO : e7xxx_probe1(pdev, ent->driver_data);
 }
 
 static void __devexit e7xxx_remove_one(struct pci_dev *pdev)
@@ -512,6 +525,9 @@ static void __devexit e7xxx_remove_one(struct pci_dev *pdev)
 
        debugf0("%s()\n", __func__);
 
+       if (e7xxx_pci)
+               edac_pci_release_generic_ctl(e7xxx_pci);
+
        if ((mci = edac_mc_del_mc(&pdev->dev)) == NULL)
                return;
 
@@ -562,7 +578,7 @@ module_exit(e7xxx_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Linux Networx (http://lnxi.com) Thayne Harbaugh et al\n"
-             "Based on.work by Dan Hollis et al");
+               "Based on.work by Dan Hollis et al");
 MODULE_DESCRIPTION("MC support for Intel e7xxx memory controllers");
 module_param(edac_op_state, int, 0444);
 MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI");