i7core_edac: return -ENODEV when devices were already probed
[pandora-kernel.git] / drivers / edac / i7core_edac.c
index 9868796..362861c 100644 (file)
@@ -353,6 +353,7 @@ static const struct pci_id_table pci_dev_table[] = {
        PCI_ID_TABLE_ENTRY(pci_dev_descr_i7core_nehalem),
        PCI_ID_TABLE_ENTRY(pci_dev_descr_lynnfield),
        PCI_ID_TABLE_ENTRY(pci_dev_descr_i7core_westmere),
+       {0,}                    /* 0 terminated list. */
 };
 
 /*
@@ -1395,6 +1396,13 @@ static int i7core_get_onedevice(struct pci_dev **prev,
                dev_descr->func,
                PCI_VENDOR_ID_INTEL, dev_descr->dev_id);
 
+       /*
+        * As stated on drivers/pci/search.c, the reference count for
+        * @from is always decremented if it is not %NULL. So, as we need
+        * to get all devices up to null, we need to do a get for the device
+        */
+       pci_dev_get(pdev);
+
        *prev = pdev;
 
        return 0;
@@ -1402,14 +1410,13 @@ static int i7core_get_onedevice(struct pci_dev **prev,
 
 static int i7core_get_all_devices(void)
 {
-       int i, j, rc, last_bus;
+       int i, rc, last_bus;
        struct pci_dev *pdev = NULL;
-       const struct pci_id_table *table;
+       const struct pci_id_table *table = pci_dev_table;
 
        last_bus = i7core_pci_lastbus();
 
-       for (j = 0; j < ARRAY_SIZE(pci_dev_table); j++) {
-               table = &pci_dev_table[j];
+       while (table && table->descr) {
                for (i = 0; i < table->n_devs; i++) {
                        pdev = NULL;
                        do {
@@ -1425,6 +1432,7 @@ static int i7core_get_all_devices(void)
                                }
                        } while (pdev);
                }
+               table++;
        }
 
        return 0;
@@ -2038,7 +2046,7 @@ static int __devinit i7core_probe(struct pci_dev *pdev,
         */
        if (unlikely(probed >= 1)) {
                mutex_unlock(&i7core_edac_lock);
-               return -EINVAL;
+               return -ENODEV;
        }
        probed++;