staging: comedi: adv_pci1723: cleanup "find pci device" code
Use for_each_pci_dev() instead of open-coding the loop using pci_get_device(). Drop the printk error messages. They just add noise. 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
05979c7b3c
commit
3dbd666ca4
@ -290,59 +290,30 @@ static int pci1723_dio_insn_bits(struct comedi_device *dev,
|
|||||||
static struct pci_dev *pci1723_find_pci_dev(struct comedi_device *dev,
|
static struct pci_dev *pci1723_find_pci_dev(struct comedi_device *dev,
|
||||||
struct comedi_devconfig *it)
|
struct comedi_devconfig *it)
|
||||||
{
|
{
|
||||||
struct pci_dev *pcidev;
|
struct pci_dev *pcidev = NULL;
|
||||||
unsigned int iobase;
|
int bus = it->options[0];
|
||||||
unsigned char pci_bus, pci_slot, pci_func;
|
int slot = it->options[1];
|
||||||
int opt_bus, opt_slot;
|
|
||||||
const char *errstr;
|
|
||||||
|
|
||||||
opt_bus = it->options[0];
|
for_each_pci_dev(pcidev) {
|
||||||
opt_slot = it->options[1];
|
if (bus || slot) {
|
||||||
|
if (bus != pcidev->bus->number ||
|
||||||
/* Look for matching PCI device */
|
slot != PCI_SLOT(pcidev->devfn))
|
||||||
errstr = "not found!";
|
continue;
|
||||||
pcidev = NULL;
|
|
||||||
while (NULL != (pcidev =
|
|
||||||
pci_get_device(PCI_VENDOR_ID_ADVANTECH,
|
|
||||||
this_board->device_id, pcidev))) {
|
|
||||||
/* Found matching vendor/device. */
|
|
||||||
if (opt_bus || opt_slot) {
|
|
||||||
/* Check bus/slot. */
|
|
||||||
if (opt_bus != pcidev->bus->number
|
|
||||||
|| opt_slot != PCI_SLOT(pcidev->devfn))
|
|
||||||
continue; /* no match */
|
|
||||||
}
|
}
|
||||||
|
if (pcidev->vendor != PCI_VENDOR_ID_ADVANTECH)
|
||||||
|
continue;
|
||||||
/*
|
/*
|
||||||
* Look for device that isn't in use.
|
* Look for device that isn't in use.
|
||||||
* Enable PCI device and request regions.
|
* Enable PCI device and request regions.
|
||||||
*/
|
*/
|
||||||
if (comedi_pci_enable(pcidev, "adv_pci1723")) {
|
if (comedi_pci_enable(pcidev, "adv_pci1723"))
|
||||||
errstr =
|
|
||||||
"failed to enable PCI device and request regions!";
|
|
||||||
continue;
|
continue;
|
||||||
}
|
return pcidev;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
dev_err(dev->class_dev,
|
||||||
if (!pcidev) {
|
"No supported board found! (req. bus %d, slot %d)\n",
|
||||||
if (opt_bus || opt_slot) {
|
bus, slot);
|
||||||
printk(KERN_ERR " - Card at b:s %d:%d %s\n",
|
return NULL;
|
||||||
opt_bus, opt_slot, errstr);
|
|
||||||
} else {
|
|
||||||
printk(KERN_ERR " - Card %s\n", errstr);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
pci_bus = pcidev->bus->number;
|
|
||||||
pci_slot = PCI_SLOT(pcidev->devfn);
|
|
||||||
pci_func = PCI_FUNC(pcidev->devfn);
|
|
||||||
iobase = pci_resource_start(pcidev, 2);
|
|
||||||
|
|
||||||
printk(KERN_ERR ", b:s:f=%d:%d:%d, io=0x%4x",
|
|
||||||
pci_bus, pci_slot, pci_func, iobase);
|
|
||||||
|
|
||||||
return pcidev;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pci1723_attach(struct comedi_device *dev,
|
static int pci1723_attach(struct comedi_device *dev,
|
||||||
|
Loading…
Reference in New Issue
Block a user