summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorH Hartley Sweeten <hartleys@visionengravers.com>2012-07-18 18:50:16 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-07-19 16:32:56 -0700
commitb8acd7750a2366216d9ec81f96b0594f6bb86707 (patch)
treeef9fd96546b09c0fce37987732bdfc364985c2b3 /drivers
parentf0bd6d357527ed40c84e75f1f3137ea944f179db (diff)
downloadlinux-3.10-b8acd7750a2366216d9ec81f96b0594f6bb86707.tar.gz
linux-3.10-b8acd7750a2366216d9ec81f96b0594f6bb86707.tar.bz2
linux-3.10-b8acd7750a2366216d9ec81f96b0594f6bb86707.zip
staging: comedi: contec_pci_dio: cleanup "find pci device" code
Add a couple local variables and reorder the tests to make to make the more concise. Change the printk to a dev_err when no match is found and reword the message. 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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/comedi/drivers/contec_pci_dio.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/drivers/staging/comedi/drivers/contec_pci_dio.c b/drivers/staging/comedi/drivers/contec_pci_dio.c
index e4d37fc0e64..b75a8afce5e 100644
--- a/drivers/staging/comedi/drivers/contec_pci_dio.c
+++ b/drivers/staging/comedi/drivers/contec_pci_dio.c
@@ -101,22 +101,25 @@ static struct pci_dev *contec_find_pci_dev(struct comedi_device *dev,
struct comedi_devconfig *it)
{
struct pci_dev *pcidev = NULL;
+ int bus = it->options[0];
+ int slot = it->options[1];
for_each_pci_dev(pcidev) {
- if (pcidev->vendor == PCI_VENDOR_ID_CONTEC &&
- pcidev->device == PCI_DEVICE_ID_PIO1616L) {
- if (it->options[0] || it->options[1]) {
- /* Check bus and slot. */
- if (it->options[0] != pcidev->bus->number ||
- it->options[1] != PCI_SLOT(pcidev->devfn)) {
- continue;
- }
- }
- dev->board_ptr = contec_boards + 0;
- return pcidev;
+ if (bus || slot) {
+ if (bus != pcidev->bus->number ||
+ slot != PCI_SLOT(pcidev->devfn))
+ continue;
}
+ if (pcidev->vendor != PCI_VENDOR_ID_CONTEC ||
+ pcidev->device != PCI_DEVICE_ID_PIO1616L)
+ continue;
+
+ dev->board_ptr = contec_boards + 0;
+ return pcidev;
}
- printk("card not present!\n");
+ dev_err(dev->class_dev,
+ "No supported board found! (req. bus %d, slot %d)\n",
+ bus, slot);
return NULL;
}