as board name when running comedi_config.
/*
Driver: adl_pci7296
Description: Driver for the Adlink PCI-7296 96 ch. digital io board
-Devices: [ADLink] PCI-7296 (pci7296)
+Devices: [ADLink] PCI-7296 (adl_pci7296)
Author: Jon Grierson <jd@renko.co.uk>
Updated: Mon, 14 Apr 2008 15:05:56 +0100
Status: testing
#define PCI_DEVICE_ID_PCI7296 0x7296
-typedef struct skel_board_struct {
- const char *name;
- int vendor_id;
- int device_id;
-} adl_pci7296_board;
-
-static const adl_pci7296_board adl_pci7296_boards[] = {
- {"pci7296", PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7296},
-};
-
static DEFINE_PCI_DEVICE_TABLE(adl_pci7296_pci_table) = {
{PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7296, PCI_ANY_ID, PCI_ANY_ID, 0,
0, 0},
MODULE_DEVICE_TABLE(pci, adl_pci7296_pci_table);
-#define thisboard ((const adl_pci7296_board *)dev->board_ptr)
-
typedef struct {
int data;
struct pci_dev *pci_dev;
module:THIS_MODULE,
attach:adl_pci7296_attach,
detach:adl_pci7296_detach,
-
- board_name:&adl_pci7296_boards[0].name,
- offset:sizeof(adl_pci7296_board),
- num_names:sizeof(adl_pci7296_boards) / sizeof(adl_pci7296_board),
};
static int adl_pci7296_attach(comedi_device * dev, comedi_devconfig * it)
int ret;
printk("comedi: attempt to attach...\n");
- printk("comedi%d: adl_pci7432: board=%s\n", dev->minor,
- thisboard->name);
+ printk("comedi%d: adl_pci7432\n", dev->minor);
- dev->board_name = thisboard->name;
+ dev->board_name = "pci7432";
bus = it->options[0];
slot = it->options[1];
dev->iobase = pci_resource_start(pcidev, 2);
printk("comedi: base addr %4lx\n", dev->iobase);
- dev->board_ptr = adl_pci7296_boards + 0;
-
// four 8255 digital io subdevices
s = dev->subdevices + 0;
subdev_8255_init(dev, s, NULL,
/*
Driver: adl_pci7432
Description: Driver for the Adlink PCI-7432 64 ch. isolated digital io board
-Devices: [ADLink] PCI-7432 (pci7432)
+Devices: [ADLink] PCI-7432 (adl_pci7432)
Author: Michel Lachaine <mike@mikelachaine.ca>
Status: experimental
Updated: Mon, 14 Apr 2008 15:08:14 +0100
#define PCI_DEVICE_ID_PCI7432 0x7432
-typedef struct {
- const char *name;
- int vendor_id;
- int device_id;
-} adl_pci7432_board;
-
-static const adl_pci7432_board adl_pci7432_boards[] = {
- {"pci7432", PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7432},
-};
-
static DEFINE_PCI_DEVICE_TABLE(adl_pci7432_pci_table) = {
{PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI7432, PCI_ANY_ID, PCI_ANY_ID, 0,
0, 0},
MODULE_DEVICE_TABLE(pci, adl_pci7432_pci_table);
-#define thisboard ((const adl_pci7432_board *)dev->board_ptr)
-
typedef struct {
int data;
struct pci_dev *pci_dev;
module:THIS_MODULE,
attach:adl_pci7432_attach,
detach:adl_pci7432_detach,
- num_names:1,
- board_name:&adl_pci7432_boards[0].name,
- offset:sizeof(adl_pci7432_board),
};
/* Digital IO */
int bus, slot;
printk("comedi: attempt to attach...\n");
- printk("comedi%d: adl_pci7432: board=%s\n", dev->minor,
- thisboard->name);
+ printk("comedi%d: adl_pci7432\n", dev->minor);
- dev->board_name = thisboard->name;
+ dev->board_name = "pci7432";
bus = it->options[0];
slot = it->options[1];
dev->iobase = pci_resource_start(pcidev, 2);
printk("comedi: base addr %4lx\n", dev->iobase);
- dev->board_ptr = adl_pci7432_boards + 0;
-
s = dev->subdevices + 0;
s->type = COMEDI_SUBD_DI;
s->subdev_flags =
/*
Driver: adl_pci8164
Description: Driver for the Adlink PCI-8164 4 Axes Motion Control board
-Devices: [ADLink] PCI-8164 (pci8164)
+Devices: [ADLink] PCI-8164 (adl_pci8164)
Author: Michel Lachaine <mike@mikelachaine.ca>
Status: experimental
Updated: Mon, 14 Apr 2008 15:10:32 +0100
#define PCI_DEVICE_ID_PCI8164 0x8164
-typedef struct {
- const char *name;
- int vendor_id;
- int device_id;
-} adl_pci8164_board;
-
-static const adl_pci8164_board adl_pci8164_boards[] = {
- {"pci8164", PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI8164},
-};
-
static DEFINE_PCI_DEVICE_TABLE(adl_pci8164_pci_table) = {
{PCI_VENDOR_ID_ADLINK, PCI_DEVICE_ID_PCI8164, PCI_ANY_ID, PCI_ANY_ID, 0,
0, 0},
MODULE_DEVICE_TABLE(pci, adl_pci8164_pci_table);
-#define thisboard ((const adl_pci8164_board *)dev->board_ptr)
-
typedef struct {
int data;
struct pci_dev *pci_dev;
module:THIS_MODULE,
attach:adl_pci8164_attach,
detach:adl_pci8164_detach,
- num_names:1,
- board_name:&adl_pci8164_boards[0].name,
- offset:sizeof(adl_pci8164_board),
};
static int adl_pci8164_insn_read_msts(comedi_device * dev, comedi_subdevice * s,
int bus, slot;
printk("comedi: attempt to attach...\n");
- printk("comedi%d: adl_pci8164: board=%s\n", dev->minor,
- thisboard->name);
+ printk("comedi%d: adl_pci8164\n", dev->minor);
- dev->board_name = thisboard->name;
+ dev->board_name = "pci8164";
bus = it->options[0];
slot = it->options[1];
dev->iobase = pci_resource_start(pcidev, 2);
printk("comedi: base addr %4lx\n", dev->iobase);
- dev->board_ptr = adl_pci8164_boards + 0;
-
s = dev->subdevices + 0;
s->type = COMEDI_SUBD_PROC;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
module:THIS_MODULE,
attach:pci9111_attach,
detach:pci9111_detach,
- num_names:pci9111_board_nbr,
- board_name:&pci9111_boards[0].name,
- offset:sizeof(pci9111_board_struct),
};
COMEDI_PCI_INITCLEANUP(pci9111_driver, pci9111_pci_table);
Description: Advantech PCI-1710, PCI-1710HG, PCI-1711, PCI-1713,
Advantech PCI-1720, PCI-1731
Author: Michal Dobes <dobes@tesnet.cz>
-Devices: [Advantech] PCI-1710 (pci1710), PCI-1710HG (pci1710hg),
- PCI-1711 (pci1711), PCI-1713 (pci1713), PCI-1720 (pci1720),
- PCI-1731 (pci1731)
+Devices: [Advantech] PCI-1710 (adv_pci1710), PCI-1710HG (pci1710hg),
+ PCI-1711 (adv_pci1710), PCI-1713, PCI-1720,
+ PCI-1731
Status: works
This driver supports AI, AO, DI and DO subdevices.
#undef PCI171X_EXTDEBUG
+#define DRV_NAME "adv_pci1710"
+
#undef DPRINTK
#ifdef PCI171X_EXTDEBUG
#define DPRINTK(fmt, args...) rt_printk(fmt, ## args)
static const boardtype boardtypes[] = {
{"pci1710", 0x1710,
- IORANGE_171x, 1, TYPE_PCI171X,
- 16, 8, 2, 16, 16, 1, 0x0fff, 0x0fff,
- &range_pci1710_3, range_codes_pci1710_3,
- &range_pci171x_da,
+ IORANGE_171x, 1, TYPE_PCI171X,
+ 16, 8, 2, 16, 16, 1, 0x0fff, 0x0fff,
+ &range_pci1710_3, range_codes_pci1710_3,
+ &range_pci171x_da,
10000, 2048},
{"pci1710hg", 0x1710,
- IORANGE_171x, 1, TYPE_PCI171X,
- 16, 8, 2, 16, 16, 1, 0x0fff, 0x0fff,
- &range_pci1710hg, range_codes_pci1710hg,
- &range_pci171x_da,
+ IORANGE_171x, 1, TYPE_PCI171X,
+ 16, 8, 2, 16, 16, 1, 0x0fff, 0x0fff,
+ &range_pci1710hg, range_codes_pci1710hg,
+ &range_pci171x_da,
10000, 2048},
{"pci1711", 0x1711,
- IORANGE_171x, 1, TYPE_PCI171X,
- 16, 0, 2, 16, 16, 1, 0x0fff, 0x0fff,
- &range_pci17x1, range_codes_pci17x1, &range_pci171x_da,
+ IORANGE_171x, 1, TYPE_PCI171X,
+ 16, 0, 2, 16, 16, 1, 0x0fff, 0x0fff,
+ &range_pci17x1, range_codes_pci17x1, &range_pci171x_da,
10000, 512},
{"pci1713", 0x1713,
- IORANGE_171x, 1, TYPE_PCI1713,
- 32, 16, 0, 0, 0, 0, 0x0fff, 0x0000,
- &range_pci1710_3, range_codes_pci1710_3, NULL,
+ IORANGE_171x, 1, TYPE_PCI1713,
+ 32, 16, 0, 0, 0, 0, 0x0fff, 0x0000,
+ &range_pci1710_3, range_codes_pci1710_3, NULL,
10000, 2048},
{"pci1720", 0x1720,
- IORANGE_1720, 0, TYPE_PCI1720,
- 0, 0, 4, 0, 0, 0, 0x0000, 0x0fff,
- NULL, NULL, &range_pci1720,
+ IORANGE_1720, 0, TYPE_PCI1720,
+ 0, 0, 4, 0, 0, 0, 0x0000, 0x0fff,
+ NULL, NULL, &range_pci1720,
0, 0},
{"pci1731", 0x1731,
- IORANGE_171x, 1, TYPE_PCI171X,
- 16, 0, 0, 16, 16, 0, 0x0fff, 0x0000,
- &range_pci17x1, range_codes_pci17x1, NULL,
+ IORANGE_171x, 1, TYPE_PCI171X,
+ 16, 0, 0, 16, 16, 0, 0x0fff, 0x0000,
+ &range_pci17x1, range_codes_pci17x1, NULL,
10000, 512},
+ // dummy entry corresponding to driver name
+ {.name = DRV_NAME},
};
#define n_boardtypes (sizeof(boardtypes)/sizeof(boardtype))
static comedi_driver driver_pci1710 = {
- driver_name:"adv_pci1710",
- module:THIS_MODULE,
- attach:pci1710_attach,
- detach:pci1710_detach,
- num_names:n_boardtypes,
- board_name:&boardtypes[0].name,
- offset:sizeof(boardtype),
+ .driver_name = DRV_NAME,
+ .module = THIS_MODULE,
+ .attach = pci1710_attach,
+ .detach = pci1710_detach,
+ .num_names = n_boardtypes,
+ .board_name = &boardtypes[0].name,
+ .offset = sizeof(boardtype),
};
typedef struct {
int opt_bus, opt_slot;
const char *errstr;
unsigned char pci_bus, pci_slot, pci_func;
+ int i;
+ int board_index;
- rt_printk("comedi%d: adv_pci1710: board=%s", dev->minor,
- this_board->name);
+ rt_printk("comedi%d: adv_pci1710: ", dev->minor);
opt_bus = it->options[0];
opt_slot = it->options[1];
/* Look for matching PCI device */
errstr = "not found!";
pcidev = NULL;
+ board_index = this_board - boardtypes;
while (NULL != (pcidev = pci_get_device(PCI_VENDOR_ID_ADVANTECH,
- this_board->device_id, pcidev))) {
+ PCI_ANY_ID, pcidev))) {
+ if(strcmp(this_board->name, DRV_NAME) == 0)
+ {
+ for(i = 0; i < n_boardtypes; ++i)
+ {
+ if(pcidev->device == boardtypes[i].device_id)
+ {
+ board_index = i;
+ break;
+ }
+ }
+ if(i == n_boardtypes) continue;
+ }else
+ {
+ if(pcidev->device != boardtypes[board_index].device_id) continue;
+ }
+
/* Found matching vendor/device. */
if (opt_bus || opt_slot) {
/* Check bus/slot. */
continue; /* no match */
}
/*
- * Look for device that isn't in use.
- * Enable PCI device and request regions.
- */
- if (comedi_pci_enable(pcidev, "adv_pci1710")) {
+ * Look for device that isn't in use.
+ * Enable PCI device and request regions.
+ */
+ if (comedi_pci_enable(pcidev, DRV_NAME)) {
errstr = "failed to enable PCI device and request regions!";
continue;
}
+ // fixup board_ptr in case we were using the dummy entry with the driver name
+ dev->board_ptr = &boardtypes[board_index];
break;
}
Driver: adv_pci1723
Description: Advantech PCI-1723
Author: yonggang <rsmgnu@gmail.com>, Ian Abbott <abbotti@mev.co.uk>
-Devices: [Advantech] PCI-1723 (pci1723)
+Devices: [Advantech] PCI-1723 (adv_pci1723)
Updated: Mon, 14 Apr 2008 15:12:56 +0100
Status: works
module:THIS_MODULE,
attach:pci1723_attach,
detach:pci1723_detach,
- num_names:n_boardtypes,
- board_name:&boardtypes[0].name,
- offset:sizeof(boardtype),
};
/* this structure is for data unique to this hardware driver. */
*/
#define devpriv ((pci1723_private *)dev->private)
-#define this_board ((const boardtype *)dev->board_ptr)
+#define this_board boardtypes
/*
* the pci1723 card reset;
Driver: das08
Description: DAS-08 compatible boards
Author: Warren Jasper, ds, Frank Hess
-Devices: [Keithley Metrabyte] DAS08 (das08), [ComputerBoards] DAS08 (das08),
+Devices: [Keithley Metrabyte] DAS08 (isa-das08), [ComputerBoards] DAS08 (isa-das08),
DAS08-PGM (das08-pgm),
DAS08-PGH (das08-pgh), DAS08-PGL (das08-pgl), DAS08-AOH (das08-aoh),
DAS08-AOL (das08-aol), DAS08-AOM (das08-aom), DAS08/JR-AO (das08/jr-ao),
- DAS08/JR-16-AO (das08jr-16-ao), PCI-DAS08 (pci-das08),
+ DAS08/JR-16-AO (das08jr-16-ao), PCI-DAS08 (das08),
PC104-DAS08 (pc104-das08), DAS08/JR/16 (das08jr/16)
Status: works
Options (for pci-das08):
[0] - bus (optional)
[1] = slot (optional)
-Use the name 'pci-das08' for the pci-das08, NOT 'das08'.
The das08 driver doesn't support asynchronous commands, since
the cheap das08 hardware doesn't really support them. The
#include "8255.h"
#include "das08.h"
+#define DRV_NAME "das08"
+
#define PCI_VENDOR_ID_COMPUTERBOARDS 0x1307
#define PCI_DEVICE_ID_PCIDAS08 0x29
#define PCIDAS08_SIZE 0x54
/*
cio-das08.pdf
- "das08"
+ "isa-das08"
0 a/d bits 0-3 start 8 bit
1 a/d bits 4-11 start 12 bit
static const struct das08_board_struct das08_boards[] = {
{
- name: "das08", // cio-das08.pdf
+ name: "isa-das08", // cio-das08.pdf
bustype: isa,
ai: das08_ai_rinsn,
ai_nbits:12,
iosize: 16, // unchecked
},
{
- name: "pci-das08",
+ name: "das08", // pci-das08
id: PCI_DEVICE_ID_PCIDAS08,
bustype: pci,
ai: das08_ai_rinsn,
static int das08_attach(comedi_device * dev, comedi_devconfig * it);
static comedi_driver driver_das08 = {
- driver_name:"das08",
+ driver_name: DRV_NAME,
module:THIS_MODULE,
attach:das08_attach,
detach:das08_common_detach,
// allocate ioports for non-pcmcia, non-pci boards
if ((thisboard->bustype != pcmcia) && (thisboard->bustype != pci)) {
printk(" iobase 0x%lx\n", iobase);
- if (!request_region(iobase, thisboard->iosize, "das08")) {
+ if (!request_region(iobase, thisboard->iosize, DRV_NAME)) {
printk(" I/O port conflict\n");
return -EIO;
}
}
devpriv->pdev = pdev;
// enable PCI device and reserve I/O spaces
- if (comedi_pci_enable(pdev, "das08")) {
+ if (comedi_pci_enable(pdev, DRV_NAME)) {
printk(" Error enabling PCI device and requesting regions\n");
return -EIO;
}
module:THIS_MODULE,
attach:me_attach,
detach:me_detach,
- num_names:me_board_nbr,
- board_name:&me_boards[0].name,
- offset:sizeof(me_board_struct),
};
COMEDI_PCI_INITCLEANUP(me_driver, me_pci_table);
Description: National Instruments Lab-PC (& compatibles)
Author: Frank Mori Hess <fmhess@users.sourceforge.net>
Devices: [National Instruments] Lab-PC-1200 (labpc-1200),
- Lab-PC-1200AI (labpc-1200ai), Lab-PC+ (lab-pc+), PCI-1200 (pci-1200)
+ Lab-PC-1200AI (labpc-1200ai), Lab-PC+ (lab-pc+), PCI-1200 (ni_labpc)
Status: works
Tested with lab-pc-1200. For the older Lab-PC+, not all input ranges
#include "comedi_fc.h"
#include "ni_labpc.h"
+#define DRV_NAME "ni_labpc"
+
#define LABPC_SIZE 32 // size of io region used by board
#define LABPC_TIMER_BASE 500 // 2 MHz master clock
static unsigned int labpc_suggest_transfer_size(comedi_cmd cmd);
static void labpc_adc_timing(comedi_device * dev, comedi_cmd * cmd);
#ifdef CONFIG_COMEDI_PCI
-static struct mite_struct *labpc_find_device(int bus, int slot);
+static int labpc_find_device(comedi_device *dev, int bus, int slot);
#endif
static int labpc_dio_mem_callback(int dir, int port, int data,
unsigned long arg);
},
#ifdef CONFIG_COMEDI_PCI
{
- name: "pci-1200",
- device_id:0x161,
- ai_speed:10000,
- bustype: pci_bustype,
- register_layout:labpc_1200_layout,
- has_ao: 1,
- ai_range_table:&range_labpc_1200_ai,
- ai_range_code:labpc_1200_ai_gain_bits,
- ai_range_is_unipolar:labpc_1200_is_unipolar,
- ai_scan_up:1,
- memory_mapped_io:1,
+ name: "pci-1200",
+ device_id:0x161,
+ ai_speed:10000,
+ bustype: pci_bustype,
+ register_layout:labpc_1200_layout,
+ has_ao: 1,
+ ai_range_table:&range_labpc_1200_ai,
+ ai_range_code:labpc_1200_ai_gain_bits,
+ ai_range_is_unipolar:labpc_1200_is_unipolar,
+ ai_scan_up:1,
+ memory_mapped_io:1,
+ },
+ // dummy entry so pci board works when comedi_config is passed driver name
+ {
+ .name = DRV_NAME,
+ .bustype = pci_bustype,
},
#endif
};
#define devpriv ((labpc_private *)dev->private)
static comedi_driver driver_labpc = {
- driver_name:"ni_labpc",
- module:THIS_MODULE,
- attach:labpc_attach,
- detach:labpc_common_detach,
- num_names:sizeof(labpc_boards) / sizeof(labpc_board),
- board_name:&labpc_boards[0].name,
- offset:sizeof(labpc_board),
+ .driver_name = DRV_NAME,
+ .module = THIS_MODULE,
+ .attach = labpc_attach,
+ .detach = labpc_common_detach,
+ .num_names = sizeof(labpc_boards) / sizeof(labpc_board),
+ .board_name = &labpc_boards[0].name,
+ .offset = sizeof(labpc_board),
};
#ifdef CONFIG_COMEDI_PCI
unsigned long iobase = 0;
unsigned int irq = 0;
unsigned int dma_chan = 0;
+ int retval;
/* allocate and initialize dev->private */
if (alloc_private(dev, sizeof(labpc_private)) < 0)
break;
case pci_bustype:
#ifdef CONFIG_COMEDI_PCI
- devpriv->mite =
- labpc_find_device(it->options[0], it->options[1]);
- if (devpriv->mite == NULL) {
- return -EIO;
- }
- if (thisboard->device_id != mite_device_id(devpriv->mite)) { // this should never happen since this driver only supports one type of pci board
- printk("bug! mite device id does not match boardtype definition\n");
- return -EINVAL;
- }
- {
- int ret = mite_setup(devpriv->mite);
- if (ret < 0)
- return ret;
+ retval = labpc_find_device(dev, it->options[0], it->options[1]);
+ if (retval < 0) {
+ return retval;
}
+ retval = mite_setup(devpriv->mite);
+ if (retval < 0)
+ return retval;
iobase = (unsigned long)devpriv->mite->daq_io_addr;
irq = mite_irq(devpriv->mite);
#else
// adapted from ni_pcimio for finding mite based boards (pc-1200)
#ifdef CONFIG_COMEDI_PCI
-static struct mite_struct *labpc_find_device(int bus, int slot)
+static int labpc_find_device(comedi_device *dev, int bus, int slot)
{
struct mite_struct *mite;
int i;
if (labpc_boards[i].bustype != pci_bustype)
continue;
if (mite_device_id(mite) == labpc_boards[i].device_id) {
- return mite;
+ devpriv->mite = mite;
+ // fixup board pointer, in case we were using the dummy "ni_labpc" entry
+ dev->board_ptr = &labpc_boards[i];
+ return 0;
}
}
}
printk("no device found\n");
mite_list_devices();
- return NULL;
+ return -EIO;
}
#endif