From: Ian Abbott Date: Mon, 14 Apr 2008 14:47:56 +0000 (+0000) Subject: Added PCI bus/slot configuration options. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6ae32f93f2c3ab0bce16a8d7a8d362616358b281;p=comedi.git Added PCI bus/slot configuration options. --- diff --git a/comedi/drivers/adl_pci7296.c b/comedi/drivers/adl_pci7296.c index b26deb9f..1cdeb7d7 100644 --- a/comedi/drivers/adl_pci7296.c +++ b/comedi/drivers/adl_pci7296.c @@ -24,11 +24,14 @@ Driver: adl_pci7296 Description: Driver for the Adlink PCI-7296 96 ch. digital io board Devices: [ADLink] PCI-7296 (pci7296) Author: Jon Grierson -Updated: 2.8.2006 +Updated: Mon, 14 Apr 2008 15:05:56 +0100 Status: testing Configuration Options: - none + [0] - PCI bus of device (optional) + [1] - PCI slot of device (optional) + If bus/slot is not specified, the first supported + PCI device found will be used. */ #include @@ -89,12 +92,16 @@ static int adl_pci7296_attach(comedi_device * dev, comedi_devconfig * it) { struct pci_dev *pcidev; comedi_subdevice *s; + int bus, slot; + int ret; printk("comedi: attempt to attach...\n"); printk("comedi%d: adl_pci7432: board=%s\n", dev->minor, thisboard->name); dev->board_name = thisboard->name; + bus = it->options[0]; + slot = it->options[1]; if (alloc_private(dev, sizeof(adl_pci7296_private)) < 0) return -ENOMEM; @@ -108,6 +115,13 @@ static int adl_pci7296_attach(comedi_device * dev, comedi_devconfig * it) if (pcidev->vendor == PCI_VENDOR_ID_ADLINK && pcidev->device == PCI_DEVICE_ID_PCI7296) { + if (bus || slot) { + /* requested particular bus/slot */ + if (pcidev->bus->number != bus + || PCI_SLOT(pcidev->devfn) != slot) { + continue; + } + } devpriv->pci_dev = pcidev; if (comedi_pci_enable(pcidev, "adl_pci7296") < 0) { printk("comedi%d: Failed to enable PCI device and request regions\n", dev->minor); @@ -125,24 +139,32 @@ static int adl_pci7296_attach(comedi_device * dev, comedi_devconfig * it) (unsigned long)(dev->iobase)); s = dev->subdevices + 1; - subdev_8255_init(dev, s, NULL, + ret = subdev_8255_init(dev, s, NULL, (unsigned long)(dev->iobase + PORT2A)); + if (ret < 0) + return ret; s = dev->subdevices + 2; - subdev_8255_init(dev, s, NULL, + ret = subdev_8255_init(dev, s, NULL, (unsigned long)(dev->iobase + PORT3A)); + if (ret < 0) + return ret; s = dev->subdevices + 3; - subdev_8255_init(dev, s, NULL, + ret = subdev_8255_init(dev, s, NULL, (unsigned long)(dev->iobase + PORT4A)); + if (ret < 0) + return ret; + + printk("attached\n"); - break; + return 1; } } - printk("attached\n"); - - return 1; + printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n", + dev->minor, bus, slot); + return -EIO; } static int adl_pci7296_detach(comedi_device * dev) diff --git a/comedi/drivers/adl_pci7432.c b/comedi/drivers/adl_pci7432.c index c00d8e6d..83b62ee0 100644 --- a/comedi/drivers/adl_pci7432.c +++ b/comedi/drivers/adl_pci7432.c @@ -25,9 +25,13 @@ Description: Driver for the Adlink PCI-7432 64 ch. isolated digital io board Devices: [ADLink] PCI-7432 (pci7432) Author: Michel Lachaine Status: experimental +Updated: Mon, 14 Apr 2008 15:08:14 +0100 Configuration Options: - none + [0] - PCI bus of device (optional) + [1] - PCI slot of device (optional) + If bus/slot is not specified, the first supported + PCI device found will be used. */ #include @@ -92,12 +96,15 @@ static int adl_pci7432_attach(comedi_device * dev, comedi_devconfig * it) { struct pci_dev *pcidev; comedi_subdevice *s; + int bus, slot; printk("comedi: attempt to attach...\n"); printk("comedi%d: adl_pci7432: board=%s\n", dev->minor, thisboard->name); dev->board_name = thisboard->name; + bus = it->options[0]; + slot = it->options[1]; if (alloc_private(dev, sizeof(adl_pci7432_private)) < 0) return -ENOMEM; @@ -111,6 +118,13 @@ static int adl_pci7432_attach(comedi_device * dev, comedi_devconfig * it) if (pcidev->vendor == PCI_VENDOR_ID_ADLINK && pcidev->device == PCI_DEVICE_ID_PCI7432) { + if (bus || slot) { + /* requested particular bus/slot */ + if (pcidev->bus->number != bus + || PCI_SLOT(pcidev->devfn) != slot) { + continue; + } + } devpriv->pci_dev = pcidev; if (comedi_pci_enable(pcidev, "adl_pci7432") < 0) { printk("comedi%d: Failed to enable PCI device and request regions\n", dev->minor); @@ -143,13 +157,15 @@ static int adl_pci7432_attach(comedi_device * dev, comedi_devconfig * it) s->range_table = &range_digital; s->insn_bits = adl_pci7432_do_insn_bits; - break; + printk("comedi: attached\n"); + + return 1; } } - printk("comedi: attached\n"); - - return 1; + printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n", + dev->minor, bus, slot); + return -EIO; } static int adl_pci7432_detach(comedi_device * dev) diff --git a/comedi/drivers/adl_pci8164.c b/comedi/drivers/adl_pci8164.c index 43b24b4f..2415b491 100644 --- a/comedi/drivers/adl_pci8164.c +++ b/comedi/drivers/adl_pci8164.c @@ -25,9 +25,13 @@ Description: Driver for the Adlink PCI-8164 4 Axes Motion Control board Devices: [ADLink] PCI-8164 (pci8164) Author: Michel Lachaine Status: experimental +Updated: Mon, 14 Apr 2008 15:10:32 +0100 Configuration Options: - none + [0] - PCI bus of device (optional) + [1] - PCI slot of device (optional) + If bus/slot is not specified, the first supported + PCI device found will be used. */ #include @@ -118,12 +122,15 @@ static int adl_pci8164_attach(comedi_device * dev, comedi_devconfig * it) { struct pci_dev *pcidev; comedi_subdevice *s; + int bus, slot; printk("comedi: attempt to attach...\n"); printk("comedi%d: adl_pci8164: board=%s\n", dev->minor, thisboard->name); dev->board_name = thisboard->name; + bus = it->options[0]; + slot = it->options[1]; if (alloc_private(dev, sizeof(adl_pci8164_private)) < 0) return -ENOMEM; @@ -137,6 +144,13 @@ static int adl_pci8164_attach(comedi_device * dev, comedi_devconfig * it) if (pcidev->vendor == PCI_VENDOR_ID_ADLINK && pcidev->device == PCI_DEVICE_ID_PCI8164) { + if (bus || slot) { + /* requested particular bus/slot */ + if (pcidev->bus->number != bus + || PCI_SLOT(pcidev->devfn) != slot) { + continue; + } + } devpriv->pci_dev = pcidev; if (comedi_pci_enable(pcidev, "adl_pci8164") < 0) { printk("comedi%d: Failed to enable PCI device and request regions\n", dev->minor); @@ -187,13 +201,15 @@ static int adl_pci8164_attach(comedi_device * dev, comedi_devconfig * it) s->insn_read = adl_pci8164_insn_read_buf1; s->insn_write = adl_pci8164_insn_write_buf1; - break; + printk("comedi: attached\n"); + + return 1; } } - printk("comedi: attached\n"); - - return 1; + printk("comedi%d: no supported board found! (req. bus/slot : %d/%d)\n", + dev->minor, bus, slot); + return -EIO; } static int adl_pci8164_detach(comedi_device * dev) diff --git a/comedi/drivers/daqboard2000.c b/comedi/drivers/daqboard2000.c index 97ab488b..cc059e42 100644 --- a/comedi/drivers/daqboard2000.c +++ b/comedi/drivers/daqboard2000.c @@ -25,6 +25,7 @@ Driver: daqboard2000 Description: IOTech DAQBoard/2000 Author: Anders Blomdell Status: works +Updated: Mon, 14 Apr 2008 15:28:52 +0100 Devices: [IOTech] DAQBoard/2000 (daqboard2000) Much of the functionality of this driver was determined from reading @@ -36,7 +37,10 @@ option. The initialization code is available from http://www.comedi.org in the comedi_nonfree_firmware tarball. Configuration options: - none + [0] - PCI bus of device (optional) + [1] - PCI slot of device (optional) + If bus/slot is not specified, the first supported + PCI device found will be used. */ /* This card was obviously never intended to leave the Windows world, @@ -720,18 +724,34 @@ static int daqboard2000_attach(comedi_device * dev, comedi_devconfig * it) struct pci_dev *card = NULL; void *aux_data; unsigned int aux_len; + int bus, slot; printk("comedi%d: daqboard2000:", dev->minor); + bus = it->options[0]; + slot = it->options[1]; + result = alloc_private(dev, sizeof(daqboard2000_private)); if (result < 0) { return -ENOMEM; } - /* FIXME: we should handle multiple cards, have to make David decide - how, so we will be consistent among all PCI card drivers... */ - card = pci_get_device(0x1616, 0x0409, NULL); + for (card = pci_get_device(0x1616, 0x0409, NULL); + card != NULL; + card = pci_get_device(0x1616, 0x0409, card)) { + if (bus || slot) { + /* requested particular bus/slot */ + if (card->bus->number != bus || + PCI_SLOT(card->devfn) != slot) { + continue; + } + } + } if (!card) { - printk(" no daqboard2000 found\n"); + if (bus || slot) + printk(" no daqboard2000 found at bus/slot: %d/%d\n", + bus, slot); + else + printk(" no daqboard2000 found\n"); return -EIO; } else { u32 id; diff --git a/comedi/drivers/dt3000.c b/comedi/drivers/dt3000.c index f9e1f6e9..7c403e45 100644 --- a/comedi/drivers/dt3000.c +++ b/comedi/drivers/dt3000.c @@ -26,8 +26,15 @@ Description: Data Translation DT3000 series Author: ds Devices: [Data Translation] DT3001 (dt3000), DT3001-PGL, DT3002, DT3003, DT3003-PGL, DT3004, DT3005, DT3004-200 +Updated: Mon, 14 Apr 2008 15:41:24 +0100 Status: works +Configuration Options: + [0] - PCI bus of device (optional) + [1] - PCI slot of device (optional) + If bus/slot is not specified, the first supported + PCI device found will be used. + There is code to support AI commands, but it may not work. AO commands are not supported. @@ -788,19 +795,22 @@ static int dt3k_mem_insn_read(comedi_device * dev, comedi_subdevice * s, return i; } -static int dt_pci_probe(comedi_device * dev); +static int dt_pci_probe(comedi_device * dev, int bus, int slot); static int dt3000_attach(comedi_device * dev, comedi_devconfig * it) { comedi_subdevice *s; + int bus, slot; int ret = 0; printk("dt3000:"); + bus = it->options[0]; + slot = it->options[1]; if ((ret = alloc_private(dev, sizeof(dt3k_private))) < 0) return ret; - ret = dt_pci_probe(dev); + ret = dt_pci_probe(dev, bus, slot); if (ret < 0) return ret; if (ret == 0) { @@ -899,12 +909,22 @@ static int dt3000_detach(comedi_device * dev) static struct pci_dev *dt_pci_find_device(struct pci_dev *from, int *board); static int setup_pci(comedi_device * dev); -static int dt_pci_probe(comedi_device * dev) +static int dt_pci_probe(comedi_device * dev, int bus, int slot) { int board; int ret; + struct pci_dev *pcidev; + + pcidev = NULL; + while ((pcidev = dt_pci_find_device(pcidev, &board)) != NULL) { + if ((bus == 0 && slot == 0) || + (pcidev->bus->number == bus && + PCI_SLOT(pcidev->devfn == slot))) { + break; + } + } + devpriv->pci_dev = pcidev; - devpriv->pci_dev = dt_pci_find_device(NULL, &board); if (board >= 0) dev->board_ptr = dt3k_boardtypes + board;