]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - drivers/edac/i7core_edac.c
i7core_edac: Avoid doing multiple probes for the same card
[net-next-2.6.git] / drivers / edac / i7core_edac.c
index d7c76800988ee453b68650809c38c489863f4050..cc9357da0e3442ad9666a415f80b3dd29321b6a0 100644 (file)
@@ -1947,21 +1947,26 @@ fail:
  *             0 for FOUND a device
  *             < 0 for error code
  */
+
+static int probed = 0;
+
 static int __devinit i7core_probe(struct pci_dev *pdev,
                                  const struct pci_device_id *id)
 {
-       int dev_idx = id->driver_data;
        int rc;
        struct i7core_dev *i7core_dev;
 
+       /* get the pci devices we want to reserve for our use */
+       mutex_lock(&i7core_edac_lock);
+
        /*
         * All memory controllers are allocated at the first pass.
         */
-       if (unlikely(dev_idx >= 1))
+       if (unlikely(probed >= 1)) {
+               mutex_unlock(&i7core_edac_lock);
                return -EINVAL;
-
-       /* get the pci devices we want to reserve for our use */
-       mutex_lock(&i7core_edac_lock);
+       }
+       probed++;
 
        rc = i7core_get_devices(pci_dev_table);
        if (unlikely(rc < 0))
@@ -2033,6 +2038,8 @@ static void __devexit i7core_remove(struct pci_dev *pdev)
                                      i7core_dev->socket);
                }
        }
+       probed--;
+
        mutex_unlock(&i7core_edac_lock);
 }