pulled from board structures.
removed dev->board in all drivers in favor of dev->board_ptr
8255: removed way-old strcmp()
cb_pcidas: fixed PCI code for 2.4
mpc8260cpm: removed comments, replaced skel with mpc8260cpm
pcl726: changed way subdevices are allocated
pcl818: changed way subdevices are allocated
int iobase;
int i;
- if(strcmp("8255",it->board_name))
- return 0;
-
printk("comedi%d: 8255:",dev->minor);
dev->board_name="8255";
static int pci9118_attach(comedi_device *dev,comedi_devconfig *it);
static int pci9118_detach(comedi_device *dev);
-static int pci9118_recognize(char *name);
-static void pci9118_register_boards(void);
typedef struct {
char *name; // driver name
module: THIS_MODULE,
attach: pci9118_attach,
detach: pci9118_detach,
- recognize: pci9118_recognize,
- register_boards: pci9118_register_boards,
num_names: n_boardtypes,
+ board_name: boardtypes,
+ offset: sizeof(boardtype),
};
typedef struct{
}pci9118_private;
#define devpriv ((pci9118_private *)dev->private)
-#define this_board (boardtypes+dev->board)
+#define this_board ((boardtype *)dev->board_ptr)
/*
==============================================================================
{
comedi_subdevice *s;
int ret,pages,i;
- unsigned int board,iobase_a,iobase_9,irq;
+ unsigned int iobase_a,iobase_9,irq;
struct amcc_struct *card=NULL;
unsigned char pci_bus,pci_slot,pci_func;
unsigned int master;
- board=dev->board;
-
- rt_printk("comedi%d: adl_pci9118: board=%s",dev->minor,boardtypes[board].name);
+ printk("comedi%d: adl_pci9118: board=%s",dev->minor,this_board->name);
if ((it->options[0]<1)&(it->options[1]<1)) { // use autodetection
- if ((card=find_free_card_by_device(boardtypes[board].device_id))==NULL) {
+ if ((card=find_free_card_by_device(this_board->device_id))==NULL) {
rt_printk(" - Unused card not found in system!\n");
return -EIO;
}
} else {
- switch (find_free_card_by_position(boardtypes[board].device_id,it->options[0],it->options[1],&card)) {
+ switch (find_free_card_by_position(this_board->device_id,it->options[0],it->options[1],&card)) {
case 1:
rt_printk(" - Card not found on requested position!\n");
return -EIO;
rt_printk(", b:s:f=%d:%d:%d, io=0x%4x, 0x%4x",pci_bus,pci_slot,pci_func,iobase_9,iobase_a);
- if (check_region(iobase_9, boardtypes[board].iorange_9118) < 0) {
+ if (check_region(iobase_9, this_board->iorange_9118) < 0) {
rt_printk("I/O port conflict\n");
return -EIO;
}
dev->iobase=iobase_9;
- dev->iosize=boardtypes[board].iorange_9118;
+ dev->iosize=this_board->iorange_9118;
request_region(dev->iobase, dev->iosize, "ADLink PCI-9118");
- dev->board_name = boardtypes[board].name;
+ dev->board_name = this_board->name;
if((ret=alloc_private(dev,sizeof(pci9118_private)))<0)
return -ENOMEM;
devpriv->amcc=card;
devpriv->master=master;
devpriv->iobase_a=iobase_a;
- devpriv->iosize_a=boardtypes[board].iorange_amcc;
+ devpriv->iosize_a=this_board->iorange_amcc;
request_region(devpriv->iobase_a, devpriv->iosize_a, "ADLink PCI-9118");
if (irq>0) {
return 0;
}
-/*
-==============================================================================
-*/
-static int pci9118_recognize(char *name)
-{
- int i;
-
- for (i = 0; i < n_boardtypes; i++) {
- if (!strcmp(boardtypes[i].name, name)) {
- return i;
- }
- }
-
- return -1;
-}
-
-void pci9118_register_boards(void)
-{
- int i;
-
- for (i = 0; i < driver_pci9118.num_names; i++) {
- driver_pci9118.board_name[i] = boardtypes[i].name;
- driver_pci9118.board_id[i] = i;
- }
-
-}
-
#ifdef MODULE
/*
==============================================================================
#include <asm/io.h>
#include <linux/comedidev.h>
-#define CB_ID 0x1307 // PCI vendor number of ComputerBoards
+#define PCI_VENDOR_CB 0x1307 // PCI vendor number of ComputerBoards
#define N_BOARDS 10 // Number of boards in cb_pcidas_boards
/* PCI-DAS base addresses */
module: THIS_MODULE,
attach: cb_pcidas_attach,
detach: cb_pcidas_detach,
+ board_name: cb_pcidas_boards,
+ num_names: sizeof(cb_pcidas_boards)/sizeof(cb_pcidas_board),
+ offset: sizeof(cb_pcidas_board),
};
static int cb_pcidas_ai_rinsn(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
/*
* Attach is called by the Comedi core to configure the driver
- * for a particular board. _recognize() has already been called,
- * and dev->board contains whatever _recognize returned.
+ * for a particular board.
*/
static int cb_pcidas_attach(comedi_device *dev, comedi_devconfig *it)
{
comedi_subdevice *s;
- struct pci_dev* pci_dev_temp;
+ struct pci_dev* pcidev;
int index;
printk("comedi%d: cb_pcidas: ",dev->minor);
/*
* Probe the device to determine what device in the series it is.
*/
- devpriv->pci_dev = NULL;
- pci_dev_temp = pci_devices;
-
printk("\n");
- while(pci_dev_temp && !devpriv->pci_dev)
- {
- if ((pci_dev_temp->bus->number == it->options[0]) &&
- (PCI_SLOT(pci_dev_temp->devfn) == it->options[1]))
- {
- devpriv->pci_dev = pci_dev_temp;
- if (pci_dev_temp->vendor == CB_ID)
- {
- index = 0;
- while((index < N_BOARDS) &&
- (cb_pcidas_boards[index].device_id !=
- pci_dev_temp->device))
- index++;
- if (index < N_BOARDS)
- {
- dev->board = index;
- printk("Found %s at requested position\n",
- cb_pcidas_boards[dev->board].name);
- }
- else
- {
- rt_printk("Not a supported ComputerBoards card on requested "
- "position\n");
- return -EIO;
+ 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;
}
- }
- else
- {
- rt_printk("Not a ComputerBoards card on requested position\n");
- return -EIO;
+ }else{
+ break;
}
}
- pci_dev_temp = pci_dev_temp->next;
}
- if (!devpriv->pci_dev)
- {
- rt_printk("No card on requested position\n");
+ if(!pcidev){
+ printk("Not a ComputerBoards card on requested position\n");
return -EIO;
}
-/*
- * Initialize devpriv->control_status and devpriv->adc_fifo to point to
- * their base address.
- */
+ for(index=0;index<N_BOARDS;index++){
+ if(cb_pcidas_boards[index].device_id == pcidev->device){
+ goto found;
+ }
+ }
+ printk("Not a supported ComputerBoards card on requested position\n");
+ return -EIO;
+
+found:
+ devpriv->pci_dev = pcidev;
+ dev->board_ptr = cb_pcidas_boards+index;
+ printk("Found %s at requested position\n",cb_pcidas_boards[index].name);
+
+ /*
+ * Initialize devpriv->control_status and devpriv->adc_fifo to point to
+ * their base address.
+ */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
devpriv->control_status =
devpriv->pci_dev->base_address[CONT_STAT_BADRINDEX] &
PCI_BASE_ADDRESS_IO_MASK;
- devpriv->adc_fifo = devpriv->pci_dev->base_address[ADC_FIFO_BADRINDEX] &
+ devpriv->adc_fifo =
+ devpriv->pci_dev->base_address[ADC_FIFO_BADRINDEX] &
+ PCI_BASE_ADDRESS_IO_MASK;
+#else
+ devpriv->control_status =
+ devpriv->pci_dev->resource[CONT_STAT_BADRINDEX].start &
+ PCI_BASE_ADDRESS_IO_MASK;
+ devpriv->adc_fifo =
+ devpriv->pci_dev->resource[ADC_FIFO_BADRINDEX].start &
PCI_BASE_ADDRESS_IO_MASK;
+#endif
/*
* Warn about the status of the driver.
*/
- if (cb_pcidas_boards[dev->board].status == 2)
+ if (thisboard->status == 2)
printk("WARNING: DRIVER FOR THIS BOARD NOT CHECKED WITH MANUAL. "
"WORKS ASSUMING FULL COMPATIBILITY WITH PCI-DAS1200. "
"PLEASE REPORT USAGE TO <ivanmr@altavista.com>.\n");
-/*
- * Initialize dev->board_ptr. This can point to an element in the
- * cb_pcidas_boards array, for quick access to board-specific information.
- */
- dev->board_ptr = cb_pcidas_boards + dev->board;
-
/*
* Initialize dev->board_name. Note that we can use the "thisboard"
* macro now, since we just initialized it in the last line.
detach: daqboard2000_detach,
};
+typedef struct {
+ char *name;
+ int id;
+}boardtype;
+static boardtype boardtypes[]={
+ { "ids2", DAQBOARD2000_SUBSYSTEM_IDS2 },
+ { "ids4", DAQBOARD2000_SUBSYSTEM_IDS4 },
+};
+#define n_boardtypes (sizeof(boardtypes)/sizeof(boardtype))
+#define this_board ((boardtype *)dev->board_ptr)
typedef struct {
enum {
if (card->hdr_type == PCI_HEADER_TYPE_NORMAL) {
u32 id;
+ int i;
pci_read_config_dword(card, PCI_SUBSYSTEM_VENDOR_ID, &id);
- switch(id){
- case DAQBOARD2000_SUBSYSTEM_IDS2:
- printk(" ids2");
- dev->board=0;
- break;
- case DAQBOARD2000_SUBSYSTEM_IDS4:
- printk(" ids4");
- dev->board=1;
- break;
- default:
- printk(" unknown subsystem id %08x\n", id);
- printk(" (pretend it is an ids2)");
- dev->board=0;
- break;
+ for(i=0;i<n_boardtypes;i++){
+ if(boardtypes[i].id==id){
+ printk(" %s",boardtypes[i].name);
+ dev->board_ptr=boardtypes+i;
+ }
+ }
+ if(!dev->board_ptr){
+ printk(" unknown subsystem id %08x (pretend it is an ids2)",id);
+ dev->board_ptr=boardtypes;
}
}else{
printk(" abnormal pci header type !?!?\n");
dev->iobase = (int)devpriv->daq;
- switch(dev->board){
- case card_daqboard_2000:
- default:
- dev->board_name = "daqboard/2000";
- break;
- }
+ dev->board_name = this_board->name;
s = dev->subdevices + 0;
/* ai subdevice */
},
#endif
};
-static int n_boardtypes = sizeof(das08_boards)/sizeof(das08_boards[0]);
+#define n_boardtypes sizeof(das08_boards)/sizeof(das08_boards[0])
struct das08_private_struct{
};
#define devpriv ((struct das08_private_struct *)dev->private)
-#define thisboard (das08_boards+dev->board)
+#define thisboard ((struct das08_board_struct *)dev->board_ptr)
#define TIMEOUT 1000
static int das08_attach(comedi_device *dev,comedi_devconfig *it);
static int das08_detach(comedi_device *dev);
-static int das08_recognize(char *name);
-static void das08_register_boards(void);
comedi_driver driver_das08={
driver_name: "das08",
module: THIS_MODULE,
attach: das08_attach,
detach: das08_detach,
- recognize: das08_recognize,
- register_boards: das08_register_boards,
- num_names: sizeof(das08_boards) / sizeof(das08_board),
+ board_name: das08_boards,
+ num_names: sizeof(das08_boards)/sizeof(struct das08_board_struct),
+ offset: sizeof(struct das08_board_struct),
};
static int das08_attach(comedi_device *dev,comedi_devconfig *it)
return -EIO;
}
- dev->board_ptr = das08_boards+dev->board;
dev->board_name = thisboard->name;
dev->iosize = DAS08_SIZE;
return 0;
}
-static int das08_recognize(char *name)
-{
- int i;
-
- for(i=0;i<n_boardtypes;i++){
- if(!strcmp(das08_boards[i].name,name))return i;
- }
-
- return -1;
-}
-
-static void das08_register_boards(void)
-{
- unsigned int i;
-
- for(i = 0; i < driver_das08.num_names; i++)
- {
- driver_das08.board_name[i] = das08_boards[i].name;
- driver_das08.board_id[i] = i;
- }
-
- return;
-}
-
-
-COMEDI_INITCLEANUP(driver_das08)
+COMEDI_INITCLEANUP(driver_das08);
#define S0 0x00
#define S1 0x02
-static int das08_attach(comedi_device *dev,comedi_devconfig *it);
-static int das08_detach(comedi_device *dev);
-static int das08_recognize(char *name);
-comedi_driver driver_das08={
- driver_name: "das08",
- module: THIS_MODULE,
- attach: das08_attach,
- detach: das08_detach,
- recognize: das08_recognize,
-};
-
-
typedef struct{
int boardtype;
int dio;
#define this_board (boardtypes[devpriv->boardtype])
#define n_boardtypes (sizeof(boardtypes)/sizeof(boardtypes[0]))
+static int das08_attach(comedi_device *dev,comedi_devconfig *it);
+static int das08_detach(comedi_device *dev);
+comedi_driver driver_das08={
+ driver_name: "das08",
+ module: THIS_MODULE,
+ attach: das08_attach,
+ detach: das08_detach,
+ board_name: boardtypes,
+ num_names: n_boardtypes,
+ offset: sizeof(struct boardtype_struct),
+};
+
+
static int das08_ai(comedi_device *dev,comedi_subdevice *s,comedi_trig *it)
{
return di_unpack(bits,it);
}
-static int das08_recognize(char *name)
-{
- int i;
-
- for(i=0;i<n_boardtypes;i++){
- if(!strcmp(boardtypes[i].name,name))return i;
- }
- return -1;
-}
-
static int das08_attach(comedi_device *dev,comedi_devconfig *it)
{
int i;
static int das16_attach(comedi_device *dev,comedi_devconfig *it);
static int das16_detach(comedi_device *dev);
-static int das16_recognize(char *name);
comedi_driver driver_das16={
driver_name: "das16",
module: THIS_MODULE,
attach: das16_attach,
detach: das16_detach,
- recognize: das16_recognize,
+/* Should be able to autodetect boards */
+#if 0
+ board_name: das16_boards,
+ num_names: n_das16_boards,
+ offset: sizeof(das16_boards[0]),
+#endif
};
}
-static int das16_recognize(char *name)
-{
- int i;
-
- for(i=0;i<n_das16_boards;i++){
- if(!strcmp(das16_boards[i].name,name))
- return i;
- }
-
- return -1;
-}
-
-
/*
*
* Options list:
if((ret=alloc_private(dev,sizeof(struct das16_private_struct)))<0)
return ret;
- dev->board = das16_probe(dev, it);
-
- dev->board_ptr = das16_boards + dev->board;
+ dev->board_ptr = das16_boards + das16_probe(dev, it);
dev->board_name = thisboard->name;
-
if(thisboard->size<0x400){
printk(" 0x%04x-0x%04x\n",
RANGE( 0, 5 )
}};
+typedef struct{
+ char *name;
+ int ai_bits;
+ comedi_lrange *bip_range;
+ comedi_lrange *unip_range;
+}boardtype;
+static boardtype boardtypes[]={
+ { "das1601/12", 12,
+ bip_range: &range_das1601_ai_10_bipolar,
+ unip_range: &range_das1601_ai_10_unipolar,
+ },
+ { "das1602/12", 12,
+ bip_range: &range_das1602_ai_10_bipolar,
+ unip_range: &range_das1602_ai_10_unipolar,
+ },
+ { "das1602/16", 16,
+ bip_range: &range_das1602_ai_10_bipolar,
+ unip_range: &range_das1602_ai_10_unipolar,
+ },
+};
+#define n_boardtypes sizeof(boardtypes)/sizeof(boardtype)
+#define this_board ((boardtype *)dev->board_ptr)
+
static int das1600_attach(comedi_device *dev,comedi_devconfig *it);
static int das1600_detach(comedi_device *dev);
-static int das1600_recognize(char *name);
comedi_driver driver_das1600={
driver_name: "das1600",
module: THIS_MODULE,
attach: das1600_attach,
detach: das1600_detach,
- recognize: das1600_recognize,
+ board_name: boardtypes,
+ num_names: n_boardtypes,
+ offset: sizeof(boardtype),
};
typedef struct {
- enum {
- card_1601_12, card_1602_12, card_1602_16
- } card;
int dma;
int crystal;
enum {
rt_printk("das1600: timeout\n");
}
- switch (devpriv->card) {
- case card_1601_12:
- case card_1602_12:
- it->data[i] = (hi << 4) | (lo >> 4);
- break;
- case card_1602_16:
- it->data[i] = (hi << 8) | lo;
- break;
+ if(this_board->ai_bits==12){
+ it->data[i] = (hi << 4) | (lo >> 4);
+ }else{
+ it->data[i] = (hi << 8) | lo;
}
}
return i;
4 == unipolar 5V (0V -- +5V)
5 == unipolar user supplied (0V -- +xV)
*/
-static int das1600_recognize(char *name)
-{
- if (!strcmp("das1601/12", name)) return card_1601_12;
- if (!strcmp("das1602/12", name)) return card_1602_12;
- if (!strcmp("das1602/16", name)) return card_1602_16;
-
- return -1;
-}
static int das1600_attach(comedi_device * dev, comedi_devconfig * it)
{
request_region(dev->iobase, DAS1600_BASE_SIZE, "das1600");
request_region(dev->iobase + 0x400, DAS1600_DIO_SIZE, "das1600");
- switch(dev->board){
- case card_1601_12:
- default:
- dev->board_name = "das1601/12";
- break;
- case card_1602_12:
- dev->board_name = "das1601/12";
- break;
- case card_1602_16:
- dev->board_name = "das1602/16";
- break;
- }
+ dev->board_name=*(char **)dev->board_ptr;
dev->n_subdevices=5;
if((result=alloc_subdevices(dev))<0)
return result;
- devpriv->card = dev->board;
devpriv->dma = it->options[2];
devpriv->crystal = it->options[3];
devpriv->adc_mux = (it->options[4] == 1) ? adc_singleended : adc_diff;
s->type = COMEDI_SUBD_AI;
s->subdev_flags = SDF_READABLE|SDF_RT;
s->n_chan = (devpriv->adc_mux == adc_singleended) ? 16 : 8;
- s->maxdata = (dev->board == card_1602_16) ? 0xffff : 0xfff;
+ s->maxdata = (1<<this_board->ai_bits)-1;
s->trig[0] = das1600_ai;
- switch (dev->board) {
- case card_1601_12:
- switch (devpriv->adc_range) {
- case adc_bipolar10:
- s->range_table = &range_das1601_ai_10_bipolar;
- break;
- case adc_unipolar10:
- s->range_table = &range_das1601_ai_10_unipolar;
- break;
- };
+ switch (devpriv->adc_range) {
+ case adc_bipolar10:
+ s->range_table = this_board->bip_range;
break;
- case card_1602_12:
- case card_1602_16:
- switch (devpriv->adc_range) {
- case adc_bipolar10:
- s->range_table = &range_das1602_ai_10_bipolar;
- break;
- case adc_unipolar10:
- s->range_table = &range_das1602_ai_10_unipolar;
- break;
- };
+ case adc_unipolar10:
+ s->range_table = this_board->unip_range;
break;
}
static int das1800_attach(comedi_device *dev, comedi_devconfig *it);
static int das1800_detach(comedi_device *dev);
-static int das1800_recognize(char *name);
-static void das1800_register_boards(void);
int das1800_probe(comedi_device *dev);
static int das1800_cancel(comedi_device *dev, comedi_subdevice *s);
static void das1800_interrupt(int irq, void *d, struct pt_regs *regs);
module: THIS_MODULE,
attach: das1800_attach,
detach: das1800_detach,
- recognize: das1800_recognize,
- register_boards: das1800_register_boards,
- num_names: sizeof(das1800_boards) / sizeof(das1800_board),
+ num_names: sizeof(das1800_boards) / sizeof(das1800_board),
+ board_name: das1800_boards,
+ offset: sizeof(das1800_board),
};
/*
int irq = it->options[1];
int dma0, dma1;
int iobase2;
+ int board;
// disable unsafe isa dma if we are using real time kernel
#ifdef CONFIG_COMEDI_RT
dev->iobase = iobase;
dev->iosize = DAS1800_SIZE;
- dev->board = das1800_probe(dev);
- if(dev->board < 0)
+ board = das1800_probe(dev);
+ if(board < 0)
{
printk("unable to determine board type\n");
return -ENODEV;
}
- dev->board_ptr = das1800_boards + dev->board;
+ dev->board_ptr = das1800_boards + board;
dev->board_name = thisboard->name;
// if it is an 'ao' board with fancy analog out then we need extra io ports
return 0;
};
-static int das1800_recognize(char *name)
-{
- if(!strcmp(name, "das-1701st"))
- return das1701st;
- if(!strcmp(name, "das-1701st-da"))
- return das1701st_da;
- if(!strcmp(name, "das-1702st"))
- return das1702st;
- if(!strcmp(name, "das-1702st-da"))
- return das1702st_da;
- if(!strcmp(name, "das-1702hr"))
- return das1702hr;
- if(!strcmp(name, "das-1702hr-da"))
- return das1702hr_da;
- if(!strcmp(name, "das-1701ao"))
- return das1701ao;
- if(!strcmp(name, "das-1702ao"))
- return das1702ao;
- if(!strcmp(name, "das-1801st"))
- return das1801st;
- if(!strcmp(name, "das-1801st-da"))
- return das1801st_da;
- if(!strcmp(name, "das-1802st"))
- return das1802st;
- if(!strcmp(name, "das-1802st-da"))
- return das1802st_da;
- if(!strcmp(name, "das-1802hr"))
- return das1802hr;
- if(!strcmp(name, "das-1802hr-da"))
- return das1802hr_da;
- if(!strcmp(name, "das-1801hc"))
- return das1801hc;
- if(!strcmp(name, "das-1802hc"))
- return das1802hc;
- if(!strcmp(name, "das-1801ao"))
- return das1801ao;
- if(!strcmp(name, "das-1802ao"))
- return das1802ao;
-
- return -1;
-}
-void das1800_register_boards(void)
-{
- int i;
-
- for(i = 0; i < driver_das1800.num_names; i++)
- {
- driver_das1800.board_name[i] = das1800_boards[i].name;
- driver_das1800.board_id[i] = i;
- }
- return;
-}
-
/* probes and checks das-1800 series board type
*/
int das1800_probe(comedi_device *dev)
{
int id;
+ int board;
+
id = (inb(dev->iobase + DAS1800_DIGITAL) >> 4) & 0xf; /* get id bits */
+ board = ((das1800_board *)dev->board_ptr) - das1800_boards;
+
switch(id)
{
// das-1800st-da
case 0x3:
- if(dev->board == das1801st_da || dev->board == das1802st_da ||
- dev->board == das1701st_da || dev->board == das1702st_da)
+ if(board == das1801st_da || board == das1802st_da ||
+ board == das1701st_da || board == das1702st_da)
{
- printk(" Board model: %s\n", (das1800_boards + dev->board)->name);
- return dev->board;
+ printk(" Board model: %s\n", das1800_boards[board].name);
+ return board;
}
printk(" Board model (probed, not recommended): das-1800st-da series\n");
return das1801st;
break;
// das-1800hr-da
case 0x4:
- if(dev->board == das1802hr_da || dev->board == das1702hr_da)
+ if(board == das1802hr_da || board == das1702hr_da)
{
- printk(" Board model: %s\n", (das1800_boards + dev->board)->name);
- return dev->board;
+ printk(" Board model: %s\n", das1800_boards[board].name);
+ return board;
}
printk(" Board model (probed, not recommended): das-1802hr-da\n");
return das1802hr;
break;
case 0x5:
- if(dev->board == das1801ao || dev->board == das1802ao ||
- dev->board == das1701ao || dev->board == das1702ao)
+ if(board == das1801ao || board == das1802ao ||
+ board == das1701ao || board == das1702ao)
{
- printk(" Board model: %s\n", (das1800_boards + dev->board)->name);
- return dev->board;
+ printk(" Board model: %s\n", das1800_boards[board].name);
+ return board;
}
printk(" Board model (probed, not recommended): das-1800ao series\n");
return das1801ao;
break;
case 0x6:
- if(dev->board == das1802hr || dev->board == das1702hr)
+ if(board == das1802hr || board == das1702hr)
{
- printk(" Board model: %s\n", (das1800_boards + dev->board)->name);
- return dev->board;
+ printk(" Board model: %s\n", das1800_boards[board].name);
+ return board;
}
printk(" Board model (probed, not recommended): das-1802hr\n");
return das1802hr;
break;
case 0x7:
- if(dev->board == das1801st || dev->board == das1802st ||
- dev->board == das1701st || dev->board == das1702st)
+ if(board == das1801st || board == das1802st ||
+ board == das1701st || board == das1702st)
{
- printk(" Board model: %s\n", (das1800_boards + dev->board)->name);
- return dev->board;
+ printk(" Board model: %s\n", das1800_boards[board].name);
+ return board;
}
printk(" Board model (probed, not recommended): das-1800st series\n");
return das1801st;
break;
case 0x8:
- if(dev->board == das1801hc || dev->board == das1802hc)
+ if(board == das1801hc || board == das1802hc)
{
- printk(" Board model: %s\n", (das1800_boards + dev->board)->name);
- return dev->board;
+ printk(" Board model: %s\n", das1800_boards[board].name);
+ return board;
}
printk(" Board model (probed, not recommended): das-1800hc series\n");
return das1801hc;
break;
default :
printk(" Board model: probe returned 0x%x (unknown)\n", id);
- return dev->board;
+ return board;
break;
}
return -1;
static int das800_attach(comedi_device *dev,comedi_devconfig *it);
static int das800_detach(comedi_device *dev);
-static int das800_recognize(char *name);
-static void das800_register_boards(void);
static int das800_cancel(comedi_device *dev, comedi_subdevice *s);
comedi_driver driver_das800={
module: THIS_MODULE,
attach: das800_attach,
detach: das800_detach,
- recognize: das800_recognize,
- register_boards: das800_register_boards,
- num_names: sizeof(das800_boards) / sizeof(das800_board),
+ num_names: sizeof(das800_boards) / sizeof(das800_board),
+ board_name: (char **)das800_boards,
+ offset: sizeof(das800_board),
};
static void das800_interrupt(int irq, void *d, struct pt_regs *regs);
int das800_set_frequency(comedi_device *dev);
int das800_load_counter(unsigned int counterNumber, unsigned int counterValue, comedi_device *dev);
-static void das800_register_boards(void)
-{
- unsigned int i;
-
- for(i = 0; i < driver_das800.num_names; i++)
- {
- driver_das800.board_name[i] = das800_boards[i].name;
- driver_das800.board_id[i] = i;
- }
-
- return;
-}
-
-static int das800_recognize(char *name)
-{
- if(!strcmp(name, "das-800") || !strcmp(name, "das800"))
- return das800;
- if(!strcmp(name, "cio-das800"))
- return ciodas800;
- if(!strcmp(name, "das-801"))
- return das801;
- if(!strcmp(name, "cio-das801"))
- return ciodas801;
- if(!strcmp(name, "das-802"))
- return das802;
- if(!strcmp(name, "cio-das802"))
- return ciodas802;
-
- return -1;
-}
-
/* checks and probes das-800 series board type */
int das800_probe(comedi_device *dev)
{
int id_bits;
unsigned long irq_flags;
+ int board;
// 'comedi spin lock irqsave' disables even rt interrupts, we use them to protect indirect addressing
comedi_spin_lock_irqsave(&devpriv->spinlock, irq_flags);
id_bits = inb(dev->iobase + DAS800_ID) & 0x3; /* get id bits */
comedi_spin_unlock_irqrestore(&devpriv->spinlock, irq_flags);
+ board = thisboard - das800_boards;
+
switch(id_bits)
{
case 0x0:
- if(dev->board == das800)
+ if(board == das800)
{
printk(" Board model: DAS-800\n");
- return dev->board;
+ return board;
}
- if(dev->board == ciodas800)
+ if(board == ciodas800)
{
printk(" Board model: CIO-DAS800\n");
- return dev->board;
+ return board;
}
printk(" Board model (probed): DAS-800\n");
return das800;
break;
case 0x2:
- if(dev->board == das801)
+ if(board == das801)
{
printk(" Board model: DAS-801\n");
- return dev->board;
+ return board;
}
- if(dev->board == ciodas801)
+ if(board == ciodas801)
{
printk(" Board model: CIO-DAS801\n");
- return dev->board;
+ return board;
}
printk(" Board model (probed): DAS-801\n");
return das801;
break;
case 0x3:
- if(dev->board == das802)
+ if(board == das802)
{
printk(" Board model: DAS-802\n");
- return dev->board;
+ return board;
}
- if(dev->board == ciodas802)
+ if(board == ciodas802)
{
printk(" Board model: CIO-DAS802\n");
- return dev->board;
+ return board;
}
printk(" Board model (probed): DAS-802\n");
return das802;
int iobase = it->options[0];
int irq = it->options[1];
unsigned long irq_flags;
+ int board;
printk("comedi%d: das800: io 0x%x", dev->minor, iobase);
if(irq)
dev->iobase = iobase;
dev->iosize = DAS800_SIZE;
- dev->board = das800_probe(dev);
- if(dev->board < 0)
+ board = das800_probe(dev);
+ if(board < 0)
{
printk("unable to determine board type\n");
return -ENODEV;
}
+ dev->board_ptr = das800_boards + board;
/* grab our IRQ */
if(irq == 1 || irq > 7 || irq < 0)
}
dev->irq = irq;
- dev->board_ptr = das800_boards + dev->board;
dev->board_name = thisboard->name;
/* allocate and initialize dev->private */
s->n_chan = 8;
s->len_chanlist = 8;
s->maxdata = 0xfff;
- s->range_table = das800_range_lkup[dev->board];
+ s->range_table = das800_range_lkup[board];
s->do_cmd = das800_ai_do_cmd;
s->do_cmdtest = das800_ai_do_cmdtest;
s->insn_read = das800_ai_rinsn;
},
};
#define n_boardtypes ((sizeof(boardtypes))/(sizeof(boardtypes[0])))
+#define boardtype (*(boardtype_t *)dev->board_ptr)
typedef struct{
- boardtype_t *board;
comedi_lrange *dac_range_types[2];
}dt2801_private;
#define devpriv ((dt2801_private *)dev->private)
-#define boardtype (*devpriv->board)
static int dt2801_ai_mode0(comedi_device *dev,comedi_subdevice *s,comedi_trig *it);
type=0;
havetype:
- printk("dt2801: %s at port 0x%x",boardtypes[type].name,iobase);
+ dev->board_ptr = boardtypes+type;
+ printk("dt2801: %s at port 0x%x",boardtype.name,iobase);
n_ai_chans=probe_number_of_ai_chans(dev);
printk(" (ai channels = %d)",n_ai_chans);
if((ret=alloc_private(dev,sizeof(dt2801_private)))<0)
goto out;
- devpriv->board=boardtypes+type;
- dev->board_name = devpriv->board->name;
+ dev->board_name = boardtype.name;
s=dev->subdevices+0;
/* ai subdevice */
#define DT2811_INTENB 0x04
#define DT2811_ADMODE 0x03
+typedef struct {
+ char *name;
+ comedi_lrange *bip_5;
+ comedi_lrange *bip_2_5;
+ comedi_lrange *unip_5;
+}boardtype;
+static boardtype boardtypes[]={
+ { "dt2811-pgh",
+ &range_dt2811_pgh_ai_5_bipolar,
+ &range_dt2811_pgh_ai_2_5_bipolar,
+ &range_dt2811_pgh_ai_5_unipolar,
+ },
+ { "dt2811-pgl",
+ &range_dt2811_pgl_ai_5_bipolar,
+ &range_dt2811_pgl_ai_2_5_bipolar,
+ &range_dt2811_pgl_ai_5_unipolar,
+ },
+};
+#define this_board ((boardtype *)dev->board_ptr)
+
static int dt2811_attach(comedi_device *dev,comedi_devconfig *it);
static int dt2811_detach(comedi_device *dev);
-static int dt2811_recognize(char *name);
comedi_driver driver_dt2811={
driver_name: "dt2811",
module: THIS_MODULE,
attach: dt2811_attach,
detach: dt2811_detach,
- recognize: dt2811_recognize,
+ board_name: boardtypes,
+ num_names: sizeof(boardtypes)/sizeof(boardtype),
+ offset: sizeof(boardtype),
};
static int dt2811_ai(comedi_device * dev, comedi_subdevice * s, comedi_trig * it);
enum {
adc_singleended, adc_diff, adc_pseudo_diff
} adc_mux;
- enum {
- adc_bipolar_5, adc_bipolar_2_5, adc_unipolar_5
- } adc_range;
enum {
dac_bipolar_5, dac_bipolar_2_5, dac_unipolar_5
} dac_range[2];
#define devpriv ((dt2811_private *)dev->private)
-static comedi_lrange *adc_range_types[][2] =
-{
- /* dt2811-pgh dt2811-pgl */
- { &range_dt2811_pgh_ai_5_bipolar, &range_dt2811_pgl_ai_5_bipolar },
- { &range_dt2811_pgh_ai_2_5_bipolar, &range_dt2811_pgl_ai_2_5_bipolar },
- { &range_dt2811_pgh_ai_5_unipolar, &range_dt2811_pgl_ai_5_unipolar }
-};
static comedi_lrange *dac_range_types[] =
{
&range_bipolar5,
1 == bipolar 2.5V (-2.5V -- +2.5V)
2 == unipolar 5V (0V -- +5V)
*/
-static int dt2811_recognize(char *name)
-{
- if(!strcmp("dt2811-pgh", name))return card_2811_pgh;
- if(!strcmp("dt2811-pgl", name))return card_2811_pgl;
-
- return -1;
-}
static int dt2811_attach(comedi_device * dev, comedi_devconfig * it)
{
long flags;
int ret;
comedi_subdevice *s;
- int board = -1;
dev->iobase = it->options[0];
}
request_region(dev->iobase, DT2811_SIZE, driver_name);
- board = dev->board;
- if (board == card_2811_pgh) {
- dev->board_name = "dt2811-pgh";
- } else if (board == card_2811_pgl) {
- dev->board_name = "dt2811-pgl";
- }
+ dev->board_name = this_board->name;
dev->iosize = DT2811_SIZE;
#if 0
case 2: devpriv->adc_mux = adc_pseudo_diff; break;
default:devpriv->adc_mux = adc_singleended; break;
}
- switch (it->options[3]) {
- case 0: devpriv->adc_range = adc_bipolar_5; break;
- case 1: devpriv->adc_range = adc_bipolar_2_5; break;
- case 2: devpriv->adc_range = adc_unipolar_5; break;
- default:devpriv->adc_range = adc_bipolar_5; break;
- }
switch (it->options[4]) {
case 0: devpriv->dac_range[0] = dac_bipolar_5; break;
case 1: devpriv->dac_range[0] = dac_bipolar_2_5; break;
s->n_chan = devpriv->adc_mux == adc_diff ? 8 : 16;
s->trig[0] = dt2811_ai;
s->maxdata = 0xfff;
- s->range_table = adc_range_types[devpriv->adc_range][board];
+ switch(it->options[3]){
+ case 0:
+ default:
+ s->range_table = this_board->bip_5;
+ break;
+ case 1:
+ s->range_table = this_board->bip_2_5;
+ break;
+ case 2:
+ s->range_table = this_board->unip_5;
+ break;
+ }
s = dev->subdevices + 1;
/* ao subdevice */
dabits: 0,
},
};
-static int n_boardtypes = sizeof(boardtypes)/sizeof(boardtype_t);
+#define n_boardtypes sizeof(boardtypes)/sizeof(boardtype_t)
+#define this_board ((boardtype_t *)dev->board_ptr)
typedef struct {
static int dt282x_attach(comedi_device * dev, comedi_devconfig * it);
static int dt282x_detach(comedi_device * dev);
-static int dt282x_recognize(char *name);
comedi_driver driver_dt282x={
driver_name: "dt282x",
module: THIS_MODULE,
attach: dt282x_attach,
detach: dt282x_detach,
- recognize: dt282x_recognize,
+ board_name: boardtypes,
+ num_names: n_boardtypes,
+ offset: sizeof(boardtype_t),
};
COMEDI_INITCLEANUP(driver_dt282x);
};
-static int dt282x_recognize(char *name)
-{
- int i;
-
- for(i=0;i<n_boardtypes;i++){
- if(!strcmp(boardtypes[i].name,name))
- return i;
- }
-
- return -1;
-}
-
/*
options:
0 i/o base
int ret;
comedi_subdevice *s;
- dev->board_ptr = boardtypes+dev->board;
- dev->board_name = boardtypes[dev->board].name;
+ dev->board_name = this_board->name;
if (it->options[opt_iobase])
dev->iobase = it->options[opt_iobase];
dabits: 12,
},
};
-static int n_dt3k_boards=sizeof(dt3k_boardtypes)/sizeof(dt3k_boardtype);
+#define n_dt3k_boards sizeof(dt3k_boardtypes)/sizeof(dt3k_boardtype)
+#define this_board ((dt3k_boardtype *)dev->board_ptr)
#define DT3000_SIZE (4*0x1000)
return -ENODEV;
}
- dev->board_name=dt3k_boardtypes[dev->board].name;
+ dev->board_name=this_board->name;
dev->n_subdevices=4;
if((ret=alloc_subdevices(dev))<0)
/* ai subdevice */
s->type=COMEDI_SUBD_AI;
s->subdev_flags=SDF_READABLE;
- s->n_chan=dt3k_boardtypes[dev->board].adchan;
+ s->n_chan=this_board->adchan;
s->trig[0]=dt3k_ai_mode0;
- s->maxdata=(1<<dt3k_boardtypes[dev->board].adbits)-1;
+ s->maxdata=(1<<this_board->adbits)-1;
s->len_chanlist=512;
s->range_table=&range_dt3000_ai; /* XXX */
s->subdev_flags=SDF_WRITEABLE;
s->n_chan=2;
s->trig[0]=dt3k_ao_mode0;
- s->maxdata=(1<<dt3k_boardtypes[dev->board].dabits)-1;
+ s->maxdata=(1<<this_board->dabits)-1;
s->len_chanlist=1;
s->range_table=&range_bipolar10;
{
devpriv->pci_bus=pci_bus;
devpriv->pci_dev_fn=pci_dev_fn;
- dev->board=i;
+ dev->board_ptr=dt3k_boards+i;
return 1;
}
}
int board;
devpriv->pci_dev=dt_pci_find_device(NULL,&board);
- dev->board=board;
+ dev->board_ptr=dt3k_boardtypes+board;
if(!devpriv->pci_dev)
return 0;
comedi_subdevice *s;
pci20xxx_subdev_private *sdp;
- dev->n_subdevices = PCI20000_MODULES+1;
+ dev->n_subdevices = 1+PCI20000_MODULES;
if ((ret = alloc_subdevices(dev)) < 0)
return ret;
if ((ret = alloc_private(dev, sizeof(pci20xxx_private))) < 0)
#include <linux/comedidev.h>
-/*
- * Board descriptions for two imaginary boards. Describing the
- * boards in this way is optional, and completely driver-dependent.
- * Some drivers use arrays such as this, other do not.
- */
-typedef struct skel_board_struct{
- char *name;
- int ai_chans;
- int ai_bits;
- int have_dio;
-}skel_board;
-skel_board skel_boards[] = {
- {
- name: "mpc8260cpm",
- },
-};
-/*
- * Useful for shorthand access to the particular board structure
- */
-#define thisboard ((skel_board *)dev->board_ptr)
-
-/* this structure is for data unique to this hardware driver. If
- several hardware drivers keep similar information in this structure,
- feel free to suggest moving the variable to the comedi_device struct. */
typedef struct{
int data;
- /* would be useful for a PCI device */
- struct pci_dev *pci_dev;
+}mpc8260cpm_private;
+#define devpriv ((mpc8260cpm_private *)dev->private)
-}skel_private;
-/*
- * most drivers define the following macro to make it easy to
- * access the private structure.
- */
-#define devpriv ((skel_private *)dev->private)
-
-/*
- * The comedi_driver structure tells the Comedi core module
- * which functions to call to configure/deconfigure (attach/detach)
- * the board, and also about the kernel module that contains
- * the device code.
- */
-static int skel_attach(comedi_device *dev,comedi_devconfig *it);
-static int skel_detach(comedi_device *dev);
-static int skel_register_boards(void);
-comedi_driver driver_skel={
+static int mpc8260cpm_attach(comedi_device *dev,comedi_devconfig *it);
+static int mpc8260cpm_detach(comedi_device *dev);
+comedi_driver driver_mpc8260cpm={
driver_name: "dummy",
module: THIS_MODULE,
- attach: skel_attach,
- detach: skel_detach,
- register_boards: skel_register_boards, // replacement for recognize
+ attach: mpc8260cpm_attach,
+ detach: mpc8260cpm_detach,
};
-static int skel_dio_config(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
-static int skel_dio_bits(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
+static int mpc8260cpm_dio_config(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
+static int mpc8260cpm_dio_bits(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
-/*
- * Attach is called by the Comedi core to configure the driver
- * for a particular board. _recognize() has already been called,
- * and dev->board contains whatever _recognize returned.
- */
-static int skel_attach(comedi_device *dev,comedi_devconfig *it)
+static int mpc8260cpm_attach(comedi_device *dev,comedi_devconfig *it)
{
comedi_subdevice *s;
int i;
- printk("comedi%d: mpc8260: ",dev->minor);
+ printk("comedi%d: mpc8260cpm: ",dev->minor);
-/*
- * Initialize dev->board_ptr. This can point to an element in the
- * skel_boards array, for quick access to board-specific information.
- */
- dev->board_ptr = skel_boards + dev->board;
+ dev->board_ptr = mpc8260cpm_boards + dev->board;
-/*
- * Initialize dev->board_name. Note that we can use the "thisboard"
- * macro now, since we just initialized it in the last line.
- */
dev->board_name = thisboard->name;
-/*
- * Allocate the private structure area.
- */
- if(alloc_private(dev,sizeof(skel_private))<0)
+ if(alloc_private(dev,sizeof(mpc8260cpm_private))<0)
return -ENOMEM;
-/*
- * Allocate the subdevice structures.
- */
dev->n_subdevices=4;
if(alloc_subdevices(dev)<0)
return -ENOMEM;
s->n_chan=32;
s->maxdata=1;
s->range_table=&range_digital;
- s->insn_config = &skel_dio_config;
- s->insn_bits = &skel_dio_bits;
+ s->insn_config = &mpc8260cpm_dio_config;
+ s->insn_bits = &mpc8260cpm_dio_bits;
}
return 1;
}
-
-/*
- * _detach is called to deconfigure a device. It should deallocate
- * resources.
- * This function is also called when _attach() fails, so it should be
- * careful not to release resources that were not necessarily
- * allocated by _attach(). dev->private and dev->subdevices are
- * deallocated automatically by the core.
- */
-static int skel_detach(comedi_device *dev)
+static int mpc8260cpm_detach(comedi_device *dev)
{
- printk("comedi%d: skel: remove\n",dev->minor);
+ printk("comedi%d: mpc8260cpm: remove\n",dev->minor);
return 0;
}
-/*
- * "instructions" read/write data in "one-shot" or "software-triggered"
- * mode.
- */
-static int skel_dio_config(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)
+static int mpc8260cpm_dio_config(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)
{
int n;
unsigned int d;
return 2;
}
-static int skel_dio_bits(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)
+static int mpc8260cpm_dio_bits(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)
{
int n;
unsigned int d;
return 2;
}
-
-
-/*
- * A convenient macro that defines init_module() and cleanup_module(),
- * as necessary.
- */
-COMEDI_INITCLEANUP(driver_skel);
+COMEDI_INITCLEANUP(driver_mpc8260cpm);
static int ni_atmio_attach(comedi_device *dev,comedi_devconfig *it);
static int ni_atmio_detach(comedi_device *dev);
-static int ni_atmio_recognize(char *name);
comedi_driver driver_atmio={
driver_name: "ni_atmio",
module: THIS_MODULE,
attach: ni_atmio_attach,
detach: ni_atmio_detach,
- recognize: ni_atmio_recognize,
};
COMEDI_INITCLEANUP(driver_atmio);
#include "ni_mio_common.c"
-static int ni_atmio_recognize(char *name)
-{
- if(!strcmp(name,"atmio-E")){
- printk("Driver name 'atmio-E' deprecated. Please use 'ni_atmio'.\n");
- return 0;
- }
- if(!strcmp(name,"ni_atmio")){
- return 0;
- }
-
- return -1;
-}
-
-
static int ni_getboardtype(comedi_device *dev);
/* clean up allocated resources */
board=ni_getboardtype(dev);
if(board<0)return -EIO;
+
+ dev->board_ptr=ni_boards + board;
- printk(" %s",ni_boards[board].name);
- dev->board_name=ni_boards[board].name;
+ printk(" %s",boardtype.name);
+ dev->board_name=boardtype.name;
/* irq stuff */
if((ret=alloc_private(dev,sizeof(ni_private)))<0)
return ret;
-
- dev->board=board;
/* generic E series stuff in ni_mio_common.c */
has_8255: 1,
},
};
-static int n_atmio16_boards=sizeof(atmio16_boards)/sizeof(atmio16_boards[0]);
+#define n_atmio16_boards sizeof(atmio16_boards)/sizeof(atmio16_boards[0])
-#define boardtype (atmio16_boards+dev->board)
+#define boardtype ((atmio16_board_t *)dev->board_ptr)
/* function prototypes */
static int atmio16d_attach(comedi_device *dev,comedi_devconfig *it);
static int atmio16d_detach(comedi_device *dev);
-static int atmio16d_recognize(char *name);
static void atmio16d_interrupt(int irq, void *d, struct pt_regs *regs);
static int atmio16d_ai_cmdtest(comedi_device *dev, comedi_subdevice *s, comedi_cmd *cmd);
static int atmio16d_ai_cmd(comedi_device *dev, comedi_subdevice *s);
module: THIS_MODULE,
attach: atmio16d_attach,
detach: atmio16d_detach,
- recognize: atmio16d_recognize,
+ board_name: atmio16_boards,
+ num_names: n_atmio16_boards,
+ offset: sizeof(atmio16_board_t),
};
/* range structs */
}
-static int atmio16d_recognize(char *name)
-{
- int i;
-
- for(i=0;i<n_atmio16_boards;i++){
- if(!strcmp(atmio16_boards[i].name,name))return i;
- }
-
- return -1;
-}
-
/*
options[0] - I/O port
options[1] - MIO irq
printk("I/O port conflict\n");
return -EIO;
}
- request_region(iobase, ATMIO16D_SIZE, "ATMIO16D");
+ request_region(iobase, ATMIO16D_SIZE, "ni_atmio16d");
dev->iobase = iobase;
dev->iosize = ATMIO16D_SIZE;
/* board name */
- if (dev->board == 0)
- dev->board_name = "at-mio16d";
- else
- dev->board_name = "unknown";
-
+ dev->board_name = boardtype->name;
/* set number of subdevices */
- if(dev->board == 0)
- dev->n_subdevices=4;
- else
- dev->n_subdevices=4;
+ dev->n_subdevices=4;
if((ret=alloc_subdevices(dev))<0)
return ret;
static int ni_read_eeprom(comedi_device *dev,int addr);
static void ni_mio_print_status_a(int status);
+#ifdef DEBUG_INTERRUPT
static void ni_mio_print_status_b(int status);
+#endif
static int ni_ai_reset(comedi_device *dev,comedi_subdevice *s);
static void ni_handle_fifo_half_full(comedi_device *dev);
}
#endif
- dev->board=ni_getboardtype(dev,link);
+ dev->board_ptr = ni_boards + ni_getboardtype(dev,link);
- printk(" %s",ni_boards[dev->board].name);
- dev->board_name=ni_boards[dev->board].name;
- dev->board_ptr = ni_boards+dev->board;
+ printk(" %s",boardtype.name);
+ dev->board_name=boardtype.name;
if( (ret=comedi_request_irq(dev->irq,ni_E_interrupt,NI_E_IRQ_FLAGS,"ni_mio_cs",dev))<0 ){
printk(" irq not available\n");
static int nidio_attach(comedi_device *dev,comedi_devconfig *it);
static int nidio_detach(comedi_device *dev);
-static int nidio_recognize(char *name);
comedi_driver driver_pcidio={
driver_name: "ni_pcidio",
module: THIS_MODULE,
attach: nidio_attach,
detach: nidio_detach,
- recognize: nidio_recognize,
};
typedef struct{
},
};
#define n_nidio_boards (sizeof(nidio_boards)/sizeof(nidio_boards[0]))
+#define this_board ((nidio_board *)dev->board_ptr)
typedef struct{
struct mite_struct *mite;
static int setup_mite(comedi_device *dev);
#endif
-static int nidio_recognize(char *name)
-{
- if(!strcmp(name,"nidio")){
- printk("name \"nidio\" deprecated. Use \"ni_pcidio\"\n");
- return 0;
- }
- if(!strcmp(name,"ni_pcidio"))
- return 0;
- return -1;
-}
-
static int nidio96_8255_cb(int dir,int port,int data,void *arg)
{
int iobase=(int)arg;
dev->iobase=mite_setup(devpriv->mite);
- dev->board_name=nidio_boards[dev->board].name;
+ dev->board_name=this_board->name;
dev->irq=mite_irq(devpriv->mite);
printk(" %s",dev->board_name);
- if(!nidio_boards[dev->board].is_diodaq){
- dev->n_subdevices=nidio_boards[dev->board].n_8255;
+ if(!this_board->is_diodaq){
+ dev->n_subdevices=this_board->n_8255;
}else{
dev->n_subdevices=1;
}
if((ret=alloc_subdevices(dev))<0)
return ret;
- if(!nidio_boards[dev->board].is_diodaq){
- for(i=0;i<nidio_boards[dev->board].n_8255;i++){
+ if(!this_board->is_diodaq){
+ for(i=0;i<this_board->n_8255;i++){
subdev_8255_init(dev,dev->subdevices+i,
nidio96_8255_cb,(void *)(dev->iobase+NIDIO_8255_BASE(i)));
}
}
for(i=0;i<n_nidio_boards;i++){
if(mite_device_id(mite)==nidio_boards[i].dev_id){
- dev->board=i;
+ dev->board_ptr=nidio_boards+i;
devpriv->mite=mite;
return 0;
static int pcimio_attach(comedi_device *dev,comedi_devconfig *it);
static int pcimio_detach(comedi_device *dev);
-static int pcimio_recognize(char *name);
comedi_driver driver_pcimio={
driver_name: "ni_pcimio",
module: THIS_MODULE,
- recognize: pcimio_recognize,
attach: pcimio_attach,
detach: pcimio_detach,
};
return 0;
}
-static int pcimio_recognize(char *name)
-{
- if(!strcmp(name,"pcimio-E")){
- printk("name \"pcimio-E\" deprecated. Use \"ni_pcimio\"\n");
- return 0;
- }
- if(!strcmp(name,"ni_pcimio"))
- return 0;
-
- return -1;
-}
-
static int pcimio_attach(comedi_device *dev,comedi_devconfig *it)
{
int ret;
ret=pcimio_find_device(dev,it->options[0],it->options[1]);
if(ret<0)return ret;
- printk(" %s",ni_boards[dev->board].name);
- dev->board_name=ni_boards[dev->board].name;
+ printk(" %s",boardtype.name);
+ dev->board_name=boardtype.name;
dev->iobase=mite_setup(devpriv->mite);
slot!=PCI_SLOT(mite->pci_device_fn))
continue;
#else
- if(bus!=mite->pcidev->bus->number<<8 ||
+ if(bus!=mite->pcidev->bus->number ||
slot!=PCI_SLOT(mite->pcidev->devfn))
continue;
#endif
for(i=0;i<n_pcimio_boards;i++){
if(mite_device_id(mite)==ni_boards[i].device_id){
- dev->board=i;
+ dev->board_ptr=ni_boards+i;
devpriv->mite=mite;
return 0;
static ni_board ni_boards[];
#define n_ni_boards (sizeof(ni_boards)/sizeof(ni_board))
-#define boardtype ni_boards[dev->board]
+#define boardtype (*(ni_board *)dev->board_ptr)
#define NI_PRIVATE_COMMON \
unsigned short dio_output; \
BIP_RANGE( 10 )
}};
-static int pcl711_attach(comedi_device *dev,comedi_devconfig *it);
-static int pcl711_detach(comedi_device *dev);
-static int pcl711_recognize(char *name);
-comedi_driver driver_pcl711={
- driver_name: "pcl711",
- module: THIS_MODULE,
- attach: pcl711_attach,
- detach: pcl711_detach,
- recognize: pcl711_recognize,
-};
-
typedef int bool;
/*
{"acl8112dg", 0, 1, 1, 9, 16, 2, 15, &range_acl8112dg_ai},
};
#define n_boardtypes (sizeof(boardtypes)/sizeof(boardtype))
+#define this_board ((boardtype *)dev->board_ptr)
+
+static int pcl711_attach(comedi_device *dev,comedi_devconfig *it);
+static int pcl711_detach(comedi_device *dev);
+comedi_driver driver_pcl711={
+ driver_name: "pcl711",
+ module: THIS_MODULE,
+ attach: pcl711_attach,
+ detach: pcl711_detach,
+ board_name: boardtypes,
+ num_names: n_boardtypes,
+ offset: sizeof(boardtype),
+};
typedef struct {
int board;
} pcl711_private;
#define devpriv ((pcl711_private *)dev->private)
-#define this_board (boardtypes+dev->board)
static void pcl711_interrupt(int irq, void *d, struct pt_regs *regs)
{
release_region(dev->iobase, dev->iosize);
}
-static int pcl711_recognize(char *name)
-{
- int i;
-
- for (i = 0; i < n_boardtypes; i++) {
- if (!strcmp(boardtypes[i].name, name)) {
- return i;
- }
- }
- return -1;
-}
-
/* Initialization */
static int pcl711_attach(comedi_device * dev, comedi_devconfig * it)
{
/* there should be a sanity check here */
/* set up some name stuff */
- dev->board_name = boardtypes[dev->board].name;
+ dev->board_name = this_board->name;
/* grab our IRQ */
irq = it->options[1];
- if (irq < 0 || irq > boardtypes[dev->board].maxirq) {
+ if (irq < 0 || irq > this_board->maxirq) {
printk("irq out of range\n");
free_resources(dev);
return -EINVAL;
return 0;
}
-#ifdef MODULE
-int init_module(void)
-{
- comedi_driver_register(&driver_pcl711);
-
- return 0;
-}
+COMEDI_INITCLEANUP(driver_pcl711);
-void cleanup_module(void)
-{
- comedi_driver_unregister(&driver_pcl711);
-}
-#endif
static int pcl724_attach(comedi_device *dev,comedi_devconfig *it);
static int pcl724_detach(comedi_device *dev);
-static int pcl724_recognize(char *name);
-
-comedi_driver driver_pcl724={
- driver_name: "pcl724",
- module: THIS_MODULE,
- attach: pcl724_attach,
- detach: pcl724_detach,
- recognize: pcl724_recognize,
-};
typedef struct {
char *name; // driver name
};
#define n_boardtypes (sizeof(boardtypes)/sizeof(boardtype))
+#define this_board ((boardtype *)dev->board_ptr)
+
+comedi_driver driver_pcl724={
+ driver_name: "pcl724",
+ module: THIS_MODULE,
+ attach: pcl724_attach,
+ detach: pcl724_detach,
+ board_name: boardtypes,
+ num_names: n_boardtypes,
+ offset: sizeof(boardtype),
+};
+
static int subdev_8255_cb(int dir,int port,int data,void *arg)
{
static int pcl724_attach(comedi_device *dev,comedi_devconfig *it)
{
- int board,iobase,iorange;
+ int iobase,iorange;
int ret,i;
- board=dev->board;
-
iobase=it->options[0];
- iorange=boardtypes[board].io_range;
- if ((boardtypes[board].can_have96)&&((it->options[1]==1)||(it->options[1]==96)))
+ iorange=this_board->io_range;
+ if ((this_board->can_have96)&&((it->options[1]==1)||(it->options[1]==96)))
iorange=PCL722_96_SIZE; // PCL-724 in 96 DIO configuration
- printk("comedi%d: pcl724: board=%s, 0x%03x ",dev->minor,boardtypes[board].name,iobase);
+ printk("comedi%d: pcl724: board=%s, 0x%03x ",dev->minor,
+ this_board->name,iobase);
if(check_region(iobase,iorange)<0){
printk("I/O port conflict\n");
return -EIO;
dev->iobase=iobase;
dev->iosize=iorange;
- dev->board_name = boardtypes[board].name;
+ dev->board_name = this_board->name;
#ifdef PCL724_IRQ
irq=0;
- if (boardtypes[board].IRQbits!=0) { /* board support IRQ */
+ if (this_board->IRQbits!=0) { /* board support IRQ */
irq=it->options[1];
if (irq>0) {/* we want to use IRQ */
- if (((1<<irq)&boardtypes[board].IRQbits)==0) {
+ if (((1<<irq)&this_board->IRQbits)==0) {
rt_printk(", IRQ %d is out of allowed range, DISABLING IT",irq);
irq=0; /* Bad IRQ */
} else {
printk("\n");
- dev->n_subdevices=boardtypes[board].numofports;
- if ((boardtypes[board].can_have96)&&((it->options[1]==1)||(it->options[1]==96)))
+ dev->n_subdevices=this_board->numofports;
+ if ((this_board->can_have96)&&((it->options[1]==1)||(it->options[1]==96)))
dev->n_subdevices=4; // PCL-724 in 96 DIO configuration
-
if((ret=alloc_subdevices(dev))<0)
return ret;
for(i=0;i<dev->n_subdevices;i++){
- if (boardtypes[board].is_pet48) {
+ if (this_board->is_pet48) {
subdev_8255_init(dev,dev->subdevices+i,
subdev_8255mapped_cb,(void *)(dev->iobase+i*0x1000));
} else
return 0;
}
-static int pcl724_recognize(char *name)
-{
- int i;
-
- for (i = 0; i < n_boardtypes; i++) {
- if (!strcmp(boardtypes[i].name, name)) {
- return i;
- }
- }
-
- return -1;
-}
-
+COMEDI_INITCLEANUP(driver_pcl724);
-#ifdef MODULE
-int init_module(void)
-{
- comedi_driver_register(&driver_pcl724);
-
- return 0;
-}
-
-void cleanup_module(void)
-{
- comedi_driver_unregister(&driver_pcl724);
-}
-#endif
/*
Options for PCL-726:
[0] - IO Base
- [1]...[6] - D/A output range for channel 1-6:
+ [2]...[7] - D/A output range for channel 1-6:
0: 0-5V, 1: 0-10V, 2: +/-5V, 3: +/-10V,
4: 4-20mA, 5: unknow (external reference)
Options for PCL-727:
[0] - IO Base
- [1]...[12] - D/A output range for channel 1-12:
+ [2]...[13] - D/A output range for channel 1-12:
0: 0-5V, 1: 0-10V, 2: +/-5V,
3: 4-20mA
Options for PCL-728 and ACL-6128:
[0] - IO Base
- [1], [2] - D/A output range for channel 1 and 2:
+ [2], [3] - D/A output range for channel 1 and 2:
0: 0-5V, 1: 0-10V, 2: +/-5V, 3: +/-10V,
4: 4-20mA, 5: 0-20mA
static int pcl726_attach(comedi_device *dev,comedi_devconfig *it);
static int pcl726_detach(comedi_device *dev);
-static int pcl726_recognize(char *name);
-
-comedi_driver driver_pcl726={
- driver_name: "pcl726",
- module: THIS_MODULE,
- attach: pcl726_attach,
- detach: pcl726_detach,
- recognize: pcl726_recognize,
-};
typedef struct {
char *name; // driver name
&rangelist_728[0], },
};
#define n_boardtypes (sizeof(boardtypes)/sizeof(boardtype))
+#define this_board ((boardtype *)dev->board_ptr)
+
+comedi_driver driver_pcl726={
+ driver_name: "pcl726",
+ module: THIS_MODULE,
+ attach: pcl726_attach,
+ detach: pcl726_detach,
+ board_name: boardtypes,
+ num_names: n_boardtypes,
+ offset: sizeof(boardtype),
+};
typedef struct{
int bipolar[12];
{
unsigned int bits;
- bits=inb(dev->iobase+boardtypes[dev->board].di_lo)|
- (inb(dev->iobase+boardtypes[dev->board].di_hi)<<8);
+ bits=inb(dev->iobase+this_board->di_lo)|
+ (inb(dev->iobase+this_board->di_hi)<<8);
return di_unpack(bits,it);
}
{
do_pack(&s->state,it);
- outb(s->state&0xff,dev->iobase+boardtypes[dev->board].do_lo);
- outb((s->state>>8),dev->iobase+boardtypes[dev->board].do_hi);
+ outb(s->state&0xff,dev->iobase+this_board->do_lo);
+ outb((s->state>>8),dev->iobase+this_board->do_hi);
return it->n_chan;
}
static int pcl726_attach(comedi_device *dev,comedi_devconfig *it)
{
comedi_subdevice *s;
- int board,iobase,iorange;
- int ret,i,fstch;
+ int iobase,iorange;
+ int ret,i;
- board=dev->board;
-
iobase=it->options[0];
- iorange=boardtypes[board].io_range;
- printk("comedi%d: pcl726: board=%s, 0x%03x ",dev->minor,boardtypes[board].name,iobase);
+ iorange=this_board->io_range;
+ printk("comedi%d: pcl726: board=%s, 0x%03x ",dev->minor,this_board->name,iobase);
if(check_region(iobase,iorange)<0){
printk("I/O port conflict\n");
return -EIO;
dev->iobase=iobase;
dev->iosize=iorange;
- dev->board_name = boardtypes[board].name;
+ dev->board_name = this_board->name;
if((ret=alloc_private(dev,sizeof(pcl726_private)))<0)
return -ENOMEM;
printk("\n");
- dev->n_subdevices=1;
- if (boardtypes[board].have_dio)
- dev->n_subdevices=3;
+ dev->n_subdevices=3;
if((ret=alloc_subdevices(dev))<0)
return ret;
/* ao */
s->type=COMEDI_SUBD_AO;
s->subdev_flags=SDF_WRITEABLE|SDF_GROUND;
- s->n_chan=boardtypes[board].n_aochan;
+ s->n_chan=this_board->n_aochan;
s->maxdata=0xfff;
s->len_chanlist=1;
s->trig[0]=pcl726_ao;
/*s->range_table=&range_unknown;*/ /* XXX */
s->range_table_list = devpriv->rangelist;
- fstch=1;
- if (board==3) fstch=2;
- for (i=0; i<boardtypes[board].n_aochan; i++) {
- if ((it->options[fstch+i]<0)||(it->options[fstch+i]>=boardtypes[board].num_of_ranges)) {
- printk("Invalid range for channel %d! Must be 0<=%d<%d\n",i+1,it->options[fstch+i],boardtypes[board].num_of_ranges-1);
- it->options[fstch+i]=0;
+ for (i=0; i<this_board->n_aochan; i++) {
+ int j;
+
+ j = it->options[2+1];
+ if ((j<0)||(j>=this_board->num_of_ranges)) {
+ printk("Invalid range for channel %d! Must be 0<=%d<%d\n",
+ i,j,this_board->num_of_ranges-1);
+ j=0;
}
- devpriv->rangelist[i]=boardtypes[board].range_type_list[it->options[fstch+i]];
+ devpriv->rangelist[i]=this_board->range_type_list[j];
if (devpriv->rangelist[i]->range[0].min==-devpriv->rangelist[i]->range[0].max)
devpriv->bipolar[i]=1; /* bipolar range */
}
- if (dev->n_subdevices<2) {
- return 0;
- }
+
s=dev->subdevices+1;
/* di */
- s->type=COMEDI_SUBD_DI;
- s->subdev_flags=SDF_READABLE|SDF_GROUND;
- s->n_chan=16;
- s->maxdata=1;
- s->len_chanlist=1;
- s->trig[0]=pcl726_di;
- s->range_table=&range_digital;
-
- if (dev->n_subdevices<3) {
- return 0;
+ if (!this_board->have_dio){
+ s->type = COMEDI_SUBD_UNUSED;
+ }else{
+ s->type=COMEDI_SUBD_DI;
+ s->subdev_flags=SDF_READABLE|SDF_GROUND;
+ s->n_chan=16;
+ s->maxdata=1;
+ s->len_chanlist=1;
+ s->trig[0]=pcl726_di;
+ s->range_table=&range_digital;
}
s=dev->subdevices+2;
/* do */
- s->type=COMEDI_SUBD_DO;
- s->subdev_flags=SDF_WRITEABLE|SDF_GROUND;
- s->n_chan=16;
- s->maxdata=1;
- s->len_chanlist=1;
- s->trig[0]=pcl726_do;
- s->range_table=&range_digital;
+ if (!this_board->have_dio){
+ s->type = COMEDI_SUBD_UNUSED;
+ }else{
+ s->type=COMEDI_SUBD_DO;
+ s->subdev_flags=SDF_WRITEABLE|SDF_GROUND;
+ s->n_chan=16;
+ s->maxdata=1;
+ s->len_chanlist=1;
+ s->trig[0]=pcl726_do;
+ s->range_table=&range_digital;
+ }
return 0;
}
return 0;
}
-static int pcl726_recognize(char *name)
-{
- int i;
-
- for (i = 0; i < n_boardtypes; i++) {
- if (!strcmp(boardtypes[i].name, name)) {
- return i;
- }
- }
-
- return -1;
-}
-
-
COMEDI_INITCLEANUP(driver_pcl726);
static int pcl812_attach(comedi_device *dev,comedi_devconfig *it);
static int pcl812_detach(comedi_device *dev);
-static int pcl812_recognize(char *name);
static int i8253_osc_base = 500; /* 2 Mhz */
-comedi_driver driver_pcl812={
- driver_name: "pcl812",
- module: THIS_MODULE,
- attach: pcl812_attach,
- detach: pcl812_detach,
- recognize: pcl812_recognize,
-};
-
typedef struct {
char *name;
+ int is_812pg;
+ int is_813b;
int n_ranges;
int n_aichan;
int ai_maxsample;
{
{
name: "pcl812pg",
+ is_812pg: 1,
n_ranges: 5,
n_aichan: 16,
ai_maxsample: 30,
},
{
name: "pcl813b",
+ is_813b: 1,
n_ranges: 4,
n_aichan: 32,
ai_maxsample: 25,
};
#define n_boardtypes (sizeof(boardtypes)/sizeof(boardtype))
+#define this_board ((boardtype *)dev->board_ptr)
+
+comedi_driver driver_pcl812={
+ driver_name: "pcl812",
+ module: THIS_MODULE,
+ attach: pcl812_attach,
+ detach: pcl812_detach,
+ board_name: boardtypes,
+ num_names: n_boardtypes,
+ offset: sizeof(boardtype),
+};
typedef struct {
#ifdef USE_DMA
} pcl812_private;
#define devpriv ((pcl812_private *)dev->private)
-#define this_board (boardtypes+dev->board)
// *INDENT-ON*
/*
*/
static void pcl812_reset(comedi_device * dev)
{
- if (dev->board == boardPCL812PG) {
+ if (this_board->is_812pg){
outb(0, dev->iobase + PCL812_DA1_LO);
outb(0, dev->iobase + PCL812_DA1_HI);
outb(0, dev->iobase + PCL812_DA2_LO);
outb(0, dev->iobase + PCL812_GAIN);
outb(0, dev->iobase + PCL812_MUX);
udelay(5);
- if (dev->board == boardPCL813B) {
+ if (this_board->is_813b){
#ifdef PCL813_MICROSECS
udelay(5);
#else
int dma;
unsigned long pages;
#endif
- int board;
comedi_subdevice *s;
int num_of_subdevs, subdevs[5];
- board = dev->board; /* inicialized from pcl812_recognize()? */
-
/* claim our I/O space */
iobase = it->options[0];
- printk("comedi%d: pcl812: board=%s, ioport=0x%03x", dev->minor, boardtypes[board].name, iobase);
- if (check_region(iobase, boardtypes[board].io_range) < 0) {
+ printk("comedi%d: pcl812: board=%s, ioport=0x%03x", dev->minor,
+ this_board->name, iobase);
+ if (check_region(iobase, this_board->io_range) < 0) {
printk("I/O port conflict\n");
return -EIO;
}
- request_region(iobase, boardtypes[board].io_range, "pcl812");
+ request_region(iobase, this_board->io_range, "pcl812");
dev->iobase = iobase;
- dev->iosize = boardtypes[board].io_range;
+ dev->iosize = this_board->io_range;
/* there should be a sanity check here */
return ret; /* Can't alloc mem */
/* set up some name stuff */
- dev->board_name = boardtypes[board].name;
+ dev->board_name = this_board->name;
/* grab our IRQ */
irq = 0;
- if (boardtypes[board].IRQbits != 0) { /* board support IRQ */
+ if (this_board->IRQbits != 0) { /* board support IRQ */
irq = it->options[1];
if (irq) { /* we want to use IRQ */
- if (((1 << irq) & boardtypes[board].IRQbits) == 0) {
+ if (((1 << irq) & this_board->IRQbits) == 0) {
printk(", IRQ %d is out of allowed range, DISABLING IT", irq);
irq = 0; /* Bad IRQ */
} else {
s->maxdata = 0xfff;
s->len_chanlist = 1024;
s->range_table = this_board->ai_range_type;
- switch (board) {
- case boardPCL812PG:
- s->subdev_flags |= SDF_GROUND;
- s->trig[0] = pcl812_ai_mode0;
+ s->subdev_flags |= SDF_GROUND;
+ s->trig[0] = pcl812_ai_mode0;
+ if(this_board->is_812pg){
if (it->options[3] == 1)
s->range_table = &range_pcl812pg2_ai;
if (dev->irq) {
s->trig[3] = pcl812_ai_mode3_int;
}
}
- break;
- case boardPCL813B:
- s->subdev_flags |= SDF_GROUND;
+ }else{
if (it->options[1] == 1)
s->range_table = &range_pcl813b2_ai;
- s->trig[0] = pcl812_ai_mode0;
- break;
}
}
s->maxdata = 0xfff;
s->len_chanlist = 1;
s->range_table = this_board->ao_range_type;
- switch (board) {
- case boardPCL812PG:
+ if(this_board->is_812pg){
s->subdev_flags |= SDF_GROUND;
s->trig[0] = pcl812_ao_mode0;
//s->trig[1] = pcl812_ao_mode1;
s->range_table = &range_unipolar5;
if (it->options[4] == 2)
s->range_table = &range_unknown;
- break;
}
}
s->maxdata = 1;
s->len_chanlist = this_board->n_dichan;
s->range_table = &range_digital;
- switch (board) {
- case boardPCL812PG:
- s->trig[0] = pcl812_di_mode0;
- break;
- }
+ s->trig[0] = pcl812_di_mode0;
}
/* digital output */
s->maxdata = 1;
s->len_chanlist = this_board->n_dochan;
s->range_table = &range_digital;
- switch (board) {
- case boardPCL812PG:
- s->trig[0] = pcl812_do_mode0;
- break;
- }
+ s->trig[0] = pcl812_do_mode0;
}
- /*dev->rem = pcl812_rem; */
-
- switch (dev->board) {
- case boardPCL812PG:
- pcl812_reset(dev);
+ pcl812_reset(dev);
+ if(this_board->is_812pg){
devpriv->max_812_ai_mode0_samples = 32;
devpriv->max_812_ai_mode0_rangewait = 1;
devpriv->max_812_ai_mode0_chanset = 1;
devpriv->max_812_ai_mode0_convstart = 5;
- break;
- case boardPCL813B:
- pcl812_reset(dev);
+ }
+ if(this_board->is_813b){
if (it->options[2] < 2) {
devpriv->max_812_ai_mode0_samples = 1;
} else {
devpriv->max_812_ai_mode0_chanset = 5000;
devpriv->max_812_ai_mode0_convstart = 20000;
#endif
- break;
}
printk("\n");
return 0;
return 0;
}
-static int pcl812_recognize(char *name)
-{
-
- int i;
-
-#ifdef MD_DEBUG
- printk("comedi: pcl812: recognize code '%s'\n", name);
-#endif
- for (i = 0; i < n_boardtypes; i++) {
- if (!strcmp(boardtypes[i].name, name)) {
-#ifdef MD_DEBUG
- printk("comedi: pcl812: recognize found '%s'\n", boardtypes[i].name);
-#endif
- return i;
- }
- }
- return -1;
-}
-
/*
==============================================================================
*/
static int pcl818_attach(comedi_device *dev,comedi_devconfig *it);
static int pcl818_detach(comedi_device *dev);
-static int pcl818_recognize(char *name);
static int RTC_lock = 0; /* RTC lock */
static int RTC_timer_lock = 0; /* RTC int lock */
-comedi_driver driver_pcl818={
- driver_name: "pcl818",
- module: THIS_MODULE,
- attach: pcl818_attach,
- detach: pcl818_detach,
- recognize: pcl818_recognize,
-};
-
typedef struct {
char *name; // driver name
int n_ranges; // len of range list
int ai_chanlist; // allowed len of channel list A/D
int ao_chanlist; // allowed len of channel list D/A
unsigned char fifo; // 1=board've FIFO
+ int is_818;
} boardtype;
static boardtype boardtypes[] =
{
{"pcl818l", 4, 16, 8, 25000, 1, 16, 16, &range_pcl818l_l_ai, &range_unipolar5, PCLx1x_RANGE, 0x00fc,
- 0x0a, 0xfff, 0xfff, 1024, 1, 0 },
+ 0x0a, 0xfff, 0xfff, 1024, 1, 0, 1 },
{"pcl818h", 9, 16, 8, 10000, 1, 16, 16, &range_pcl818h_ai, &range_unipolar5, PCLx1x_RANGE, 0x00fc,
- 0x0a, 0xfff, 0xfff, 1024, 1, 0 },
+ 0x0a, 0xfff, 0xfff, 1024, 1, 0, 1 },
{"pcl818hd", 9, 16, 8, 10000, 1, 16, 16, &range_pcl818h_ai, &range_unipolar5, PCLx1x_RANGE, 0x00fc,
- 0x0a, 0xfff, 0xfff, 1024, 1, 1 },
+ 0x0a, 0xfff, 0xfff, 1024, 1, 1, 1 },
{"pcl818hg", 12, 16, 8, 10000, 1, 16, 16, &range_pcl818hg_ai, &range_unipolar5, PCLx1x_RANGE, 0x00fc,
- 0x0a, 0xfff, 0xfff, 1024, 1, 1 },
+ 0x0a, 0xfff, 0xfff, 1024, 1, 1, 1 },
{"pcl818", 9, 16, 8, 10000, 2, 16, 16, &range_pcl818h_ai, &range_unipolar5, PCLx1x_RANGE, 0x00fc,
- 0x0a, 0xfff, 0xfff, 1024, 2, 0 },
+ 0x0a, 0xfff, 0xfff, 1024, 2, 0, 1 },
{"pcl718", 1, 16, 8, 16000, 2, 16, 16, &range_unipolar5, &range_unipolar5, PCLx1x_RANGE, 0x00fc,
- 0x0a, 0xfff, 0xfff, 1024, 2, 0 },
+ 0x0a, 0xfff, 0xfff, 1024, 2, 0, 0 },
/* pcm3718 */
{"pcm3718", 9, 16, 8, 10000, 0, 16, 16, &range_pcl818h_ai, &range_unipolar5, PCLx1x_RANGE, 0x00fc,
- 0x0a, 0xfff, 0xfff, 1024, 0, 0 },
+ 0x0a, 0xfff, 0xfff, 1024, 0, 0, 1 /* XXX ? */ },
};
#define n_boardtypes (sizeof(boardtypes)/sizeof(boardtype))
+comedi_driver driver_pcl818={
+ driver_name: "pcl818",
+ module: THIS_MODULE,
+ attach: pcl818_attach,
+ detach: pcl818_detach,
+ board_name: boardtypes,
+ num_names: n_boardtypes,
+ offset: sizeof(boardtype),
+};
+
+
typedef struct {
int dma; // used DMA, 0=don't use DMA
int dma_rtc; // 1=RTC used with DMA, 0=no RTC alloc
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};
#define devpriv ((pcl818_private *)dev->private)
-#define this_board (boardtypes+dev->board)
+#define this_board ((boardtype *)dev->board_ptr)
/*
==============================================================================
outb(0xb0, dev->iobase + PCL818_CTRCTL);/* Stop pacer */
outb(0x70, dev->iobase + PCL818_CTRCTL);
outb(0x30, dev->iobase + PCL818_CTRCTL);
- switch (dev->board) {
- case boardPCL818L:
- case boardPCL818H:
- case boardPCL818HD:
- case boardPCL818HG:
+ if(this_board->is_818){
outb(0, dev->iobase + PCL818_RANGE);
- break;
- case boardPCL818:
- outb(0, dev->iobase + PCL818_RANGE);
- case boardPCL718:
+ }else{
outb(0, dev->iobase + PCL718_DA2_LO);
outb(0, dev->iobase + PCL718_DA2_HI);
- break;
}
}
int iobase;
int irq,dma;
unsigned long pages;
- int i;
- int board,io_range;
+ int io_range;
comedi_subdevice *s;
- int num_of_subdevs, subdevs[5];
- board = dev->board; /* inicialized from pcl812_recognize()? */
-
/* claim our I/O space */
iobase = it->options[0];
- rt_printk("comedi%d: pcl818: board=%s, ioport=0x%03x", dev->minor, boardtypes[board].name, iobase);
- io_range=boardtypes[board].io_range;
- if ((boardtypes[board].fifo)&&(it->options[2]==0)) // we've board with FIFO and we want to use FIFO
+ printk("comedi%d: pcl818: board=%s, ioport=0x%03x",
+ dev->minor, this_board->name, iobase);
+ io_range=this_board->io_range;
+ if ((this_board->fifo)&&(it->options[2]==0)) // we've board with FIFO and we want to use FIFO
io_range=PCLx1xFIFO_RANGE;
if (check_region(iobase, io_range) < 0) {
rt_printk("I/O port conflict\n");
dev->iosize=io_range;
if (pcl818_check(iobase)) {
- rt_printk(", I cann't detect board. FAIL!\n");
+ rt_printk(", I can't detect board. FAIL!\n");
return -EIO;
}
return ret; /* Can't alloc mem */
/* set up some name stuff */
- dev->board_name = boardtypes[board].name;
+ dev->board_name = this_board->name;
if (io_range==PCLx1xFIFO_RANGE) devpriv->usefifo=1;
/* grab our IRQ */
irq=0;
- if (boardtypes[board].IRQbits!=0) { /* board support IRQ */
+ if (this_board->IRQbits!=0) { /* board support IRQ */
irq=it->options[1];
if (irq>0) {/* we want to use IRQ */
- if (((1<<irq)&boardtypes[board].IRQbits)==0) {
+ if (((1<<irq)&this_board->IRQbits)==0) {
rt_printk(", IRQ %d is out of allowed range, DISABLING IT",irq);
irq=0; /* Bad IRQ */
} else {
dma=0;
devpriv->dma=dma;
if ((devpriv->irq_free==0)&&(devpriv->dma_rtc==0)) goto no_dma; /* if we haven't IRQ, we can't use DMA */
- if (boardtypes[board].DMAbits!=0) { /* board support DMA */
+ if (this_board->DMAbits!=0) { /* board support DMA */
dma=it->options[2];
if (dma<1) goto no_dma; /* DMA disabled */
- if (((1<<dma)&boardtypes[board].DMAbits)==0) {
+ if (((1<<dma)&this_board->DMAbits)==0) {
rt_printk(", DMA is out of allowed range, FAIL!\n");
return -EINVAL; /* Bad DMA */
}
no_dma:
- num_of_subdevs=0;
-
- if ((this_board->n_aichan_se>0)||(this_board->n_aichan_diff>0)) subdevs[num_of_subdevs++]=COMEDI_SUBD_AI;
- if (this_board->n_aochan>0) subdevs[num_of_subdevs++]=COMEDI_SUBD_AO;
- if (this_board->n_dichan>0) subdevs[num_of_subdevs++]=COMEDI_SUBD_DI;
- if (this_board->n_dochan>0) subdevs[num_of_subdevs++]=COMEDI_SUBD_DO;
-
- dev->n_subdevices = num_of_subdevs;
- if((ret=alloc_subdevices(dev))<0)
- return ret;
+ dev->n_subdevices = 4;
+ if((ret=alloc_subdevices(dev))<0) return ret;
s = dev->subdevices + 0;
- for (i = 0; i < num_of_subdevs; i++) {
- s->type = subdevs[i];
- switch (s->type) {
- case COMEDI_SUBD_AI:
- devpriv->sub_ai=s;
- s->subdev_flags = SDF_READABLE|SDF_RT;
- if (check_single_ended(dev->iobase)) {
- s->n_chan = this_board->n_aichan_se;
- s->subdev_flags|=SDF_COMMON|SDF_GROUND;
- rt_printk(", %dchans S.E. DAC",s->n_chan);
- } else {
- s->n_chan = this_board->n_aichan_diff;
- s->subdev_flags|=SDF_DIFF;
- rt_printk(", %dchans DIFF DAC",s->n_chan);
+ if(!this_board->n_aichan_se){
+ s->type = COMEDI_SUBD_UNUSED;
+ }else{
+ s->type = COMEDI_SUBD_AI;
+ devpriv->sub_ai=s;
+ s->subdev_flags = SDF_READABLE|SDF_RT;
+ if (check_single_ended(dev->iobase)) {
+ s->n_chan = this_board->n_aichan_se;
+ s->subdev_flags|=SDF_COMMON|SDF_GROUND;
+ rt_printk(", %dchans S.E. DAC",s->n_chan);
+ } else {
+ s->n_chan = this_board->n_aichan_diff;
+ s->subdev_flags|=SDF_DIFF;
+ rt_printk(", %dchans DIFF DAC",s->n_chan);
+ }
+ s->maxdata = this_board->ai_maxdata;
+ s->len_chanlist = this_board->ai_chanlist;
+ s->range_table = this_board->ai_range_type;
+ s->cancel=pcl818_ai_cancel;
+ s->trig[0] = pcl818_ai_mode0;
+ if ((irq)||(devpriv->dma_rtc)) {
+ s->trig[1] = pcl818_ai_mode1;
+ s->trig[3] = pcl818_ai_mode3;
+ }
+ if(this_board->is_818){
+ if ((it->options[4]==1)||(it->options[4]==10))
+ s->range_table=&range_pcl818l_h_ai; // secondary range list jumper selectable
+ }else{
+ switch (it->options[4]) {
+ case 0: s->range_table=&range_bipolar10; break;
+ case 1: s->range_table=&range_bipolar5; break;
+ case 2: s->range_table=&range_bipolar2_5; break;
+ case 3: s->range_table=&range718_bipolar1; break;
+ case 4: s->range_table=&range718_bipolar0_5; break;
+ case 6: s->range_table=&range_unipolar10; break;
+ case 7: s->range_table=&range_unipolar5; break;
+ case 8: s->range_table=&range718_unipolar2; break;
+ case 9: s->range_table=&range718_unipolar1; break;
+ default: s->range_table=&range_unknown; break;
}
- s->maxdata = this_board->ai_maxdata;
- s->len_chanlist = this_board->ai_chanlist;
- s->range_table = this_board->ai_range_type;
- s->cancel=pcl818_ai_cancel;
- s->trig[0] = pcl818_ai_mode0;
- if ((irq)||(devpriv->dma_rtc)) {
- s->trig[1] = pcl818_ai_mode1;
- s->trig[3] = pcl818_ai_mode3;
- }
- switch (board) {
- case boardPCL818L:
- if ((it->options[4]==1)||(it->options[4]==10))
- s->range_table=&range_pcl818l_h_ai; // secondary range list jumper selectable
- break;
- case boardPCL718:
- switch (it->options[4]) {
- case 0: s->range_table=&range_bipolar10; break;
- case 1: s->range_table=&range_bipolar5; break;
- case 2: s->range_table=&range_bipolar2_5; break;
- case 3: s->range_table=&range718_bipolar1; break;
- case 4: s->range_table=&range718_bipolar0_5; break;
- case 6: s->range_table=&range_unipolar10; break;
- case 7: s->range_table=&range_unipolar5; break;
- case 8: s->range_table=&range718_unipolar2; break;
- case 9: s->range_table=&range718_unipolar1; break;
- default: s->range_table=&range_unknown; break;
- }
- break;
- }
- break;
-
- case COMEDI_SUBD_AO:
- s->subdev_flags = SDF_WRITEABLE|SDF_GROUND|SDF_RT;
- s->n_chan = this_board->n_aochan;
- s->maxdata = this_board->ao_maxdata;
- s->len_chanlist = this_board->ao_chanlist;
- s->range_table = this_board->ao_range_type;
- s->trig[0] = pcl818_ao_mode0;
+ }
+ }
+
+ s = dev->subdevices + 1;
+ if(!this_board->n_aochan){
+ s->type = COMEDI_SUBD_UNUSED;
+ }else{
+ s->type = COMEDI_SUBD_AO;
+ s->subdev_flags = SDF_WRITEABLE|SDF_GROUND|SDF_RT;
+ s->n_chan = this_board->n_aochan;
+ s->maxdata = this_board->ao_maxdata;
+ s->len_chanlist = this_board->ao_chanlist;
+ s->range_table = this_board->ao_range_type;
+ s->trig[0] = pcl818_ao_mode0;
#ifdef PCL818_MODE13_AO
- if (irq) {
- s->trig[1] = pcl818_ao_mode1;
- s->trig[3] = pcl818_ao_mode3;
- }
+ if (irq) {
+ s->trig[1] = pcl818_ao_mode1;
+ s->trig[3] = pcl818_ao_mode3;
+ }
#endif
- switch (board) {
- case boardPCL818:
- case boardPCL818H:
- case boardPCL818HD:
- case boardPCL818HG:
- if ((it->options[4]==1)||(it->options[4]==10))
- s->range_table=&range_unipolar10;
- if (it->options[4]==2)
- s->range_table=&range_unknown;
- break;
- case boardPCL718:
- case boardPCL818L:
- if ((it->options[5]==1)||(it->options[5]==10))
- s->range_table=&range_unipolar10;
- if (it->options[5]==2)
- s->range_table=&range_unknown;
- break;
- }
- break;
+ if(this_board->is_818){
+ if ((it->options[4]==1)||(it->options[4]==10))
+ s->range_table=&range_unipolar10;
+ if (it->options[4]==2)
+ s->range_table=&range_unknown;
+ }else{
+ if ((it->options[5]==1)||(it->options[5]==10))
+ s->range_table=&range_unipolar10;
+ if (it->options[5]==2)
+ s->range_table=&range_unknown;
+ }
+ }
- case COMEDI_SUBD_DI:
- s->subdev_flags = SDF_READABLE|SDF_RT;
- s->n_chan = this_board->n_dichan;
- s->maxdata = 1;
- s->len_chanlist = this_board->n_dichan;
- s->range_table = &range_digital;
- s->trig[0] = pcl818_di_mode0;
- break;
+ s = dev->subdevices + 2;
+ if(!this_board->n_dichan){
+ s->type = COMEDI_SUBD_UNUSED;
+ }else{
+ s->type = COMEDI_SUBD_DI;
+ s->subdev_flags = SDF_READABLE|SDF_RT;
+ s->n_chan = this_board->n_dichan;
+ s->maxdata = 1;
+ s->len_chanlist = this_board->n_dichan;
+ s->range_table = &range_digital;
+ s->trig[0] = pcl818_di_mode0;
+ }
- case COMEDI_SUBD_DO:
- s->subdev_flags = SDF_WRITEABLE|SDF_RT;
- s->n_chan = this_board->n_dochan;
- s->maxdata = 1;
- s->len_chanlist = this_board->n_dochan;
- s->range_table = &range_digital;
- s->trig[0] = pcl818_do_mode0;
- break;
- }
- s++;
+ s = dev->subdevices + 3;
+ if(!this_board->n_dochan){
+ s->type = COMEDI_SUBD_UNUSED;
+ }else{
+ s->type = COMEDI_SUBD_DO;
+ s->subdev_flags = SDF_WRITEABLE|SDF_RT;
+ s->n_chan = this_board->n_dochan;
+ s->maxdata = 1;
+ s->len_chanlist = this_board->n_dochan;
+ s->range_table = &range_digital;
+ s->trig[0] = pcl818_do_mode0;
}
/* select 1/10MHz oscilator */
}
/* max sampling speed */
- devpriv->ns_min=boardtypes[dev->board].ns_min;
+ devpriv->ns_min=this_board->ns_min;
- switch (dev->board) {
- case boardPCL718:
+ if(!this_board->is_818){
if ((it->options[6]==1)||(it->options[6]==100))
devpriv->ns_min=10000; /* extended PCL718 to 100kHz DAC */
- break;
}
pcl818_reset(dev);
return 0;
}
-static int pcl818_recognize(char *name)
-{
- int i;
-
- // rt_printk("comedi: pcl818: recognize code '%s'\n",name);
- for (i = 0; i < n_boardtypes; i++) {
- if (!strcmp(boardtypes[i].name, name)) {
- // rt_printk("comedi: pcl818: recognize found %d '%s'\n", i,boardtypes[i].name);
- return i;
- }
- }
-
- return -1;
-}
-
/*
==============================================================================
*/
static int poc_detach(comedi_device *dev);
static int dac02_ao_winsn(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
static int readback_insn(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
-static int poc_recognize(char *name);
struct boarddef_struct{
char *name;
}
};
#define n_boards (sizeof(boards)/sizeof(boards[0]))
+#define this_board ((struct boarddef_struct *)dev->board_ptr)
comedi_driver driver_poc=
{
module: THIS_MODULE,
attach: poc_attach,
detach: poc_detach,
- recognize: poc_recognize,
+ board_name: boards,
+ num_names: n_boards,
+ offset: sizeof(boards[0]),
};
// analog output ranges
}
};
-static int poc_recognize(char *name)
-{
- int i;
-
- for(i=0;i<n_boards;i++){
- if(!strcmp(boards[i].name,name))
- return i;
- }
-
- return -1;
-}
-
static int poc_attach(comedi_device *dev, comedi_devconfig *it)
{
comedi_subdevice *s;
iobase = it->options[0];
printk("comedi%d: poc: using %s iobase 0x%x\n", dev->minor,
- boards[dev->board].name, iobase);
+ this_board->name, iobase);
- dev->board_name = boards[dev->board].name;
+ dev->board_name = this_board->name;
if(iobase == 0)
{
return -EINVAL;
}
- iosize = boards[dev->board].iosize;
+ iosize = this_board->iosize;
/* check if io addresses are available */
if(check_region(iobase, iosize) < 0)
{
dev->n_subdevices = 1;
if(alloc_subdevices(dev) < 0)
return -ENOMEM;
- if(alloc_private(dev,sizeof(lsampl_t)*boards[dev->board].n_chan) < 0)
+ if(alloc_private(dev,sizeof(lsampl_t)*this_board->n_chan) < 0)
return -ENOMEM;
/* analog output subdevice */
s=dev->subdevices + 0;
- s->type = boards[dev->board].type;
- s->n_chan = boards[dev->board].n_chan;
- s->maxdata = (1<<boards[dev->board].n_bits)-1;
+ s->type = this_board->type;
+ s->n_chan = this_board->n_chan;
+ s->maxdata = (1<<this_board->n_bits)-1;
s->range_table = &range_dac02; // XXX
- s->insn_write = boards[dev->board].winsn;
- s->insn_write = boards[dev->board].rinsn;
+ s->insn_write = this_board->winsn;
+ s->insn_write = this_board->rinsn;
if(s->type==COMEDI_SUBD_AO || s->type==COMEDI_SUBD_DO){
s->subdev_flags = SDF_WRITEABLE;
}
static int daqp_detach(comedi_device *dev);
comedi_driver driver_daqp={
driver_name: "daqp",
- module: &__this_module,
+ module: THIS_MODULE,
attach: daqp_attach,
detach: daqp_detach,
};
UNI_RANGE( 0.02 )
}};
+typedef struct{
+ char *name;
+ int has_ao;
+}boardtype;
+static boardtype boardtypes[]={
+ { "rti800", 0 },
+ { "rti815", 1 },
+};
+#define this_board ((boardtype *)dev->board_ptr)
+
static int rti800_attach(comedi_device *dev,comedi_devconfig *it);
static int rti800_detach(comedi_device *dev);
-static int rti800_recognize(char *name);
comedi_driver driver_rti800={
driver_name: "rti800",
module: THIS_MODULE,
attach: rti800_attach,
detach: rti800_detach,
- recognize: rti800_recognize,
+ num_names: sizeof(boardtypes)/sizeof(boardtype),
+ board_name: boardtypes,
+ offset: sizeof(boardtype),
};
static void rti800_interrupt(int irq, void *dev, struct pt_regs *regs);
options[8] - dac1 coding
*/
-static int rti800_recognize(char *name)
-{
- if (!strcmp("rti800", name))return 0;
- if (!strcmp("rti815", name))return 1;
-
- return -1;
-}
-
static int rti800_attach(comedi_device * dev, comedi_devconfig * it)
{
int irq;
printk("( no irq )");
}
- if (dev->board == 0)
- dev->board_name = "rti800";
- else
- dev->board_name = "rti815";
+ dev->board_name = this_board->name;
-
- if (dev->board != 0) {
- dev->n_subdevices=4;
- }else{
- dev->n_subdevices=3;
- }
+ dev->n_subdevices=4;
if((ret=alloc_subdevices(dev))<0)
return ret;
if((ret=alloc_private(dev,sizeof(rti800_private)))<0)
break;
}
- if (dev->board == 1) {
- s++;
+ s++;
+ if (this_board->has_ao){
/* ao subdevice (only on rti815) */
s->type=COMEDI_SUBD_AO;
s->subdev_flags=SDF_WRITEABLE;
devpriv->ao_range_type_list[1] = &range_unipolar10;
break;
}
+ }else{
+ s->type=COMEDI_SUBD_UNUSED;
}
s++;
*/
static int skel_attach(comedi_device *dev,comedi_devconfig *it);
static int skel_detach(comedi_device *dev);
-//static int skel_recognize(char *name);
-static void skel_register_boards(void);
comedi_driver driver_skel={
driver_name: "dummy",
module: THIS_MODULE,
attach: skel_attach,
detach: skel_detach,
/* It is not necessary to implement the following members if you are
- * writing a driver for a plug and play card.
- */
-// recognize: skel_recognize,
- register_boards: skel_register_boards, // replacement for recognize
- /* comedi uses num_names to allocate the board_name and board_id members
- * of this struct
+ * writing a driver for a ISA PnP or PCI card */
+ /* Most drivers will support multiple types of boards by
+ * having an array of board structures. These were defined
+ * in skel_boards[] above. Note that the element 'name'
+ * was first in the structure -- Comedi uses this fact to
+ * extract the name of the board without knowing any details
+ * about the structure except for its length.
+ * When a device is attached (by comedi_config), the name
+ * of the device is given to Comedi, and Comedi tries to
+ * match it by going through the list of board names. If
+ * there is a match, the address of the pointer is put
+ * into dev->board_ptr and driver->attach() is called.
+ *
+ * Note that these are not necessary if you can determine
+ * the type of board in software. ISA PnP, PCI, and PCMCIA
+ * devices are such boards.
*/
- num_names: sizeof(skel_boards) / sizeof(skel_board),
+ board_name: skel_boards,
+ offset: sizeof(skel_board),
+ num_names: sizeof(skel_boards) / sizeof(skel_board),
};
static int skel_ai_rinsn(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data);
comedi_cmd *cmd);
static int skel_ns_to_timer(unsigned int *ns,int round);
-/*
- * The function skel_recognize() is called when the Comedi core
- * gets a request to configure a device. If the name of the device
- * being configured matches with one of the devices that this
- * driver can service, then a non-negative index should be returned.
- * This index is put into dev->board, and then _attach() is called.
- */
-
-/*
-static int skel_recognize(char *name)
-{
- if(!strcmp("skel-100",name))return 0;
- if(!strcmp("skel-200",name))return 1;
-
- return -1;
-}
-*/
-
-/* The function register_boards() is a replacement for recognize
- * that allows comedi to report back valid board names when it doesn't
- * recognize a board name. The job of register_boards is to
- * initialize the board_name and board_id members of
- * the the comedi_driver_struct for this driver. The arrays
- * will have already been allocated with num_names elements
- * (your driver must initialize the num_names member of your
- * comedi_driver struct) by comedi_driver_register()
- * in the drivers.c file.
- */
-static void skel_register_boards(void)
-{
- unsigned int i;
-
- for(i = 0; i < driver_skel.num_names; i++)
- {
- driver_skel.board_name[i] = skel_boards[i].name;
- driver_skel.board_id[i] = i;
- }
-
- return;
-}
-
/*
* Attach is called by the Comedi core to configure the driver
- * for a particular board. _recognize() has already been called,
- * and dev->board contains whatever _recognize returned.
+ * for a particular board. If you specified a board_name array
+ * in the driver structure, dev->board_ptr contains that
+ * address.
*/
static int skel_attach(comedi_device *dev,comedi_devconfig *it)
{
/*
* If you can probe the device to determine what device in a series
- * it is, this is the place to do it. Otherwise, you should use the
- * _recognize method, and use the value in dev->board.
- */
- //dev->board = skel_recognize(dev);
-
-/*
- * Initialize dev->board_ptr. This can point to an element in the
- * skel_boards array, for quick access to board-specific information.
+ * it is, this is the place to do it. Otherwise, dev->board_ptr
+ * should already be initialized.
*/
- dev->board_ptr = skel_boards + dev->board;
+ //dev->board_ptr = skel_probe(dev);
/*
* Initialize dev->board_name. Note that we can use the "thisboard"
dev->board_name = thisboard->name;
/*
- * Allocate the private structure area.
+ * Allocate the private structure area. alloc_private() is a
+ * convenient macro defined in comedidev.h.
*/
if(alloc_private(dev,sizeof(skel_private))<0)
return -ENOMEM;
/*
- * Allocate the subdevice structures.
+ * Allocate the subdevice structures. alloc_subdevice() is a
+ * convenient macro defined in comedidev.h. It relies on
+ * n_subdevices being set correctly.
*/
dev->n_subdevices=3;
if(alloc_subdevices(dev)<0)