Commit 2605d35b authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: amplc_pci230: cleanup "find pci device" code

For aesthetic reasons, rename the function and pass the
comedi_devconfig struct instead of pre-parsing out the bus/slot
information.

Consolidate the dev_err messages when a pci device is not found.
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 41541704
...@@ -2683,11 +2683,13 @@ static const struct pci230_board *pci230_find_pci_board(struct pci_dev *pci_dev) ...@@ -2683,11 +2683,13 @@ static const struct pci230_board *pci230_find_pci_board(struct pci_dev *pci_dev)
} }
/* Look for PCI device matching requested board name, bus and slot. */ /* Look for PCI device matching requested board name, bus and slot. */
static struct pci_dev *pci230_find_pci(struct comedi_device *dev, static struct pci_dev *pci230_find_pci_dev(struct comedi_device *dev,
int bus, int slot) struct comedi_devconfig *it)
{ {
const struct pci230_board *thisboard = comedi_board(dev); const struct pci230_board *thisboard = comedi_board(dev);
struct pci_dev *pci_dev = NULL; struct pci_dev *pci_dev = NULL;
int bus = it->options[0];
int slot = it->options[1];
for_each_pci_dev(pci_dev) { for_each_pci_dev(pci_dev) {
/* Check vendor ID (same for all supported PCI boards). */ /* Check vendor ID (same for all supported PCI boards). */
...@@ -2707,23 +2709,16 @@ static struct pci_dev *pci230_find_pci(struct comedi_device *dev, ...@@ -2707,23 +2709,16 @@ static struct pci_dev *pci230_find_pci(struct comedi_device *dev,
continue; continue;
/* Replace wildcard board_ptr. */ /* Replace wildcard board_ptr. */
dev->board_ptr = foundboard; dev->board_ptr = foundboard;
thisboard = comedi_board(dev);
} else { } else {
/* Need to match a specific board. */ /* Need to match a specific board. */
if (!pci230_match_pci_board(thisboard, pci_dev)) if (!pci230_match_pci_board(thisboard, pci_dev))
continue; continue;
} }
/* Found a matching PCI device. */
return pci_dev; return pci_dev;
} }
/* No matching PCI device found. */ dev_err(dev->class_dev,
if (bus || slot) "No supported board found! (req. bus %d, slot %d)\n",
dev_err(dev->class_dev, bus, slot);
"error! no %s found at pci %02x:%02x\n",
thisboard->name, bus, slot);
else
dev_err(dev->class_dev,
"error! no %s found\n", thisboard->name);
return NULL; return NULL;
} }
...@@ -2909,8 +2904,7 @@ static int pci230_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -2909,8 +2904,7 @@ static int pci230_attach(struct comedi_device *dev, struct comedi_devconfig *it)
rc = pci230_alloc_private(dev); /* sets dev->private */ rc = pci230_alloc_private(dev); /* sets dev->private */
if (rc) if (rc)
return rc; return rc;
/* Find card. */ pci_dev = pci230_find_pci_dev(dev, it);
pci_dev = pci230_find_pci(dev, it->options[0], it->options[1]);
if (!pci_dev) if (!pci_dev)
return -EIO; return -EIO;
return pci230_attach_common(dev, pci_dev); return pci230_attach_common(dev, pci_dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment