Commit b8acd775 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman
Browse files

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: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f0bd6d35
Loading
Loading
Loading
Loading
+15 −12
Original line number Diff line number Diff line
@@ -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)) {
		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;
}