staging: comedi: adv_pci1723: move comedi_pci_enable() into the attach
authorH Hartley Sweeten <hartleys@visionengravers.com>
Thu, 19 Jul 2012 01:30:48 +0000 (18:30 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Jul 2012 23:19:41 +0000 (16:19 -0700)
Use pci_is_enabled() in the "find pci device" function to determine if
the found pci device is not in use and move the comedi_pci_enable() call
into the attach.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/adv_pci1723.c

index f561a2a605461f84fd576fdfc4a86da3704a42e3..e971fa61bbe1cbc9cd8e5ac14c994e30d5309af5 100644 (file)
@@ -302,11 +302,7 @@ static struct pci_dev *pci1723_find_pci_dev(struct comedi_device *dev,
                }
                if (pcidev->vendor != PCI_VENDOR_ID_ADVANTECH)
                        continue;
-               /*
-                * Look for device that isn't in use.
-                * Enable PCI device and request regions.
-                */
-               if (comedi_pci_enable(pcidev, "adv_pci1723"))
+               if (pci_is_enabled(pcidev))
                        continue;
                return pcidev;
        }
@@ -335,6 +331,10 @@ static int pci1723_attach(struct comedi_device *dev,
        if (!devpriv->pcidev)
                return -EIO;
 
+       ret = comedi_pci_enable(devpriv->pcidev, "adv_pci1723");
+       if (ret)
+               return ret;
+
        dev->iobase = pci_resource_start(devpriv->pcidev, 2);
 
        dev->board_name = this_board->name;