From 778c3bcff2138825303e151737a2df422a0be297 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Thu, 9 Aug 2001 17:20:41 +0000 Subject: [PATCH] fixed pci autodetection that could have been confused by a second computer boards card being present that was not supported by this driver. --- comedi/drivers/cb_pcidas.c | 60 ++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/comedi/drivers/cb_pcidas.c b/comedi/drivers/cb_pcidas.c index d424fe34..f6d78c2f 100644 --- a/comedi/drivers/cb_pcidas.c +++ b/comedi/drivers/cb_pcidas.c @@ -43,7 +43,9 @@ TODO: add a calibration subdevice -add analog out support +add analog out support for 1600 series + +fix pci detection to ignore unsupported boards from computerboards */ #include @@ -136,7 +138,10 @@ add analog out support #define DACEN 0x2 // dac enable #define DAC_RANGE(channel, range) (((range) & 0x3) << (8 + 2 * channel) ) // dac range -/* ADC data, FIFO clear registers */ +// analog output registers for 100x, 1200 series +#define DAC_DATA_REG(channel) ((channel) & 0x1) + +/* analog output registers for 1602 series*/ #define ADCDATA 0 // ADC DATA register #define ADCFIFOCLR 2 // ADC FIFO CLEAR @@ -144,9 +149,6 @@ add analog out support #define ADC8254 0 #define DIO_8255 4 -// analog output registers -#define DAC_DATA_REG(channel) ((channel) & 0x1) - // bit in hexadecimal representation of range index that indicates unipolar input range #define IS_UNIPOLAR 0x4 // analog input ranges for most boards @@ -395,40 +397,40 @@ static int cb_pcidas_attach(comedi_device *dev, comedi_devconfig *it) */ printk("\n"); - pci_for_each_dev(pcidev){ - if(pcidev->vendor==PCI_VENDOR_CB){ - if(it->options[0] || it->options[1]){ - if(pcidev->bus->number==it->options[0] && - PCI_SLOT(pcidev->devfn)==it->options[1]){ - break; + pci_for_each_dev(pcidev) + { + // is it not a computer boards card? + if(pcidev->vendor != PCI_VENDOR_CB) + continue; + // loop through cards supported by this driver + for(index = 0; index < N_BOARDS; index++) + { + if(cb_pcidas_boards[index].device_id != pcidev->device) + continue; + // was a particular bus/slot requested? + if(it->options[0] || it->options[1]) + { + // are we on the wrong bus/slot? + if(pcidev->bus->number != it->options[0] || + PCI_SLOT(pcidev->devfn) != it->options[1]) + { + continue; } - }else{ - break; } - } - } - - if(!pcidev){ - printk("Not a ComputerBoards/MeasurementComputing card on requested " - "position\n"); - return -EIO; - } - - for(index=0;indexdevice){ + devpriv->pci_dev = pcidev; + dev->board_ptr = cb_pcidas_boards + index; goto found; } } - printk("Not a supported ComputerBoards/MeasurementComputing card on " + + printk("No supported ComputerBoards/MeasurementComputing card found on " "requested position\n"); return -EIO; found: - devpriv->pci_dev = pcidev; - dev->board_ptr = cb_pcidas_boards+index; - // thisboard macro can be used from here - printk("Found %s at requested position\n",cb_pcidas_boards[index].name); + printk("Found %s on bus %i, slot %i\n", cb_pcidas_boards[index].name, + devpriv->pci_dev->bus->number, PCI_SLOT(devpriv->pci_dev->devfn)); // Warn about non-tested features switch(thisboard->device_id) -- 2.26.2