staging: comedi: dyna_pci10xx: cleanup "find pci device" code
Cleanup the "find pci device" code so that it follows the style of the other comedi pci drivers. 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>
This commit is contained in:
parent
1f20b973f6
commit
5d30e51909
1 changed files with 17 additions and 41 deletions
|
@ -233,55 +233,31 @@ static struct pci_dev *dyna_pci10xx_find_pci_dev(struct comedi_device *dev,
|
||||||
struct comedi_devconfig *it)
|
struct comedi_devconfig *it)
|
||||||
{
|
{
|
||||||
struct pci_dev *pcidev = NULL;
|
struct pci_dev *pcidev = NULL;
|
||||||
int opt_bus = it->options[0];
|
int bus = it->options[0];
|
||||||
int opt_slot = it->options[1];
|
int slot = it->options[1];
|
||||||
int board_index;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
|
for_each_pci_dev(pcidev) {
|
||||||
pcidev != NULL;
|
if (bus || slot) {
|
||||||
pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) {
|
if (bus != pcidev->bus->number ||
|
||||||
|
slot != PCI_SLOT(pcidev->devfn))
|
||||||
board_index = -1;
|
continue;
|
||||||
for (i = 0; i < ARRAY_SIZE(boardtypes); ++i) {
|
|
||||||
if ((pcidev->vendor == PCI_VENDOR_ID_DYNALOG) &&
|
|
||||||
(pcidev->device == boardtypes[i].device_id)) {
|
|
||||||
board_index = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (board_index < 0)
|
if (pcidev->vendor != PCI_VENDOR_ID_DYNALOG)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Found matching vendor/device. */
|
for (i = 0; i < ARRAY_SIZE(boardtypes); ++i) {
|
||||||
if (opt_bus || opt_slot) {
|
if (pcidev->device != boardtypes[i].device_id)
|
||||||
/* Check bus/slot. */
|
continue;
|
||||||
if (opt_bus != pcidev->bus->number
|
|
||||||
|| opt_slot != PCI_SLOT(pcidev->devfn))
|
|
||||||
continue; /* no match */
|
|
||||||
}
|
|
||||||
|
|
||||||
goto found;
|
dev->board_ptr = &boardtypes[i];
|
||||||
|
return pcidev;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
printk(KERN_ERR "comedi: dyna_pci10xx: no supported device found!\n");
|
dev_err(dev->class_dev,
|
||||||
|
"No supported board found! (req. bus %d, slot %d)\n",
|
||||||
|
bus, slot);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
found:
|
|
||||||
|
|
||||||
if (!pcidev) {
|
|
||||||
if (opt_bus || opt_slot) {
|
|
||||||
printk(KERN_ERR "comedi: dyna_pci10xx: "
|
|
||||||
"invalid PCI device at b:s %d:%d\n",
|
|
||||||
opt_bus, opt_slot);
|
|
||||||
} else {
|
|
||||||
printk(KERN_ERR "comedi: dyna_pci10xx: "
|
|
||||||
"invalid PCI device\n");
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev->board_ptr = &boardtypes[board_index];
|
|
||||||
return pcidev;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dyna_pci10xx_attach(struct comedi_device *dev,
|
static int dyna_pci10xx_attach(struct comedi_device *dev,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue