From: H Hartley Sweeten Date: Thu, 19 Jul 2012 01:32:01 +0000 (-0700) Subject: staging: comedi: adv_pci1710: move comedi_pci_enable() into the attach X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5f5d1b9ac13d44f370a3f7ebfc624b7f6cca4c19;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git staging: comedi: adv_pci1710: move comedi_pci_enable() into the attach 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 Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 5eecf6bc31e3..33dd1db1d96b 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -1350,6 +1350,8 @@ static struct pci_dev *pci1710_find_pci_dev(struct comedi_device *dev, } if (pcidev->vendor != PCI_VENDOR_ID_ADVANTECH) continue; + if (pci_is_enabled(pcidev)) + continue; if (strcmp(this_board->name, DRV_NAME) == 0) { for (i = 0; i < ARRAY_SIZE(boardtypes); ++i) { @@ -1364,15 +1366,6 @@ static struct pci_dev *pci1710_find_pci_dev(struct comedi_device *dev, if (pcidev->device != boardtypes[board_index].device_id) continue; } - - /* - * Look for device that isn't in use. - * Enable PCI device and request regions. - */ - if (comedi_pci_enable(pcidev, DRV_NAME)) { - continue; - } - /* fixup board_ptr in case we were using the dummy entry with the driver name */ dev->board_ptr = &boardtypes[board_index]; return pcidev; } @@ -1399,6 +1392,10 @@ static int pci1710_attach(struct comedi_device *dev, if (!devpriv->pcidev) return -EIO; + ret = comedi_pci_enable(devpriv->pcidev, DRV_NAME); + if (ret) + return ret; + dev->iobase = pci_resource_start(devpriv->pcidev, 2); irq = devpriv->pcidev->irq;