From 2714a23e541e136fb52f7681395a25c6e7e93e43 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Thu, 24 May 2001 01:28:08 +0000 Subject: [PATCH] Code cleanup, mainly things noticed by check_driver. A couple of the drivers were converted to insn. --- comedi/drivers/8255.c | 8 +- comedi/drivers/8255.h | 11 +-- comedi/drivers/adl_pci9118.c | 6 +- comedi/drivers/comedi_parport.c | 10 +-- comedi/drivers/comedi_rt_timer.c | 8 +- comedi/drivers/daqboard2000.c | 98 +++++++++++++---------- comedi/drivers/das08.c | 16 ++-- comedi/drivers/das16.c | 43 ++++++----- comedi/drivers/das1800.c | 10 +-- comedi/drivers/das6402.c | 2 +- comedi/drivers/das800.c | 10 +-- comedi/drivers/dt2814.c | 10 +-- comedi/drivers/dt282x.c | 20 ++--- comedi/drivers/fl512.c | 10 ++- comedi/drivers/multiq3.c | 129 ++++++++++++++++++------------- comedi/drivers/ni_atmio.c | 2 + comedi/drivers/ni_atmio16d.c | 74 +++++++++--------- comedi/drivers/ni_mio_common.c | 7 +- comedi/drivers/ni_pcidio.c | 8 ++ comedi/drivers/ni_pcimio.c | 2 + comedi/drivers/pcl711.c | 2 +- comedi/drivers/pcl724.c | 6 ++ comedi/drivers/rti802.c | 10 ++- comedi/drivers/skel.c | 26 +++++-- 24 files changed, 312 insertions(+), 216 deletions(-) diff --git a/comedi/drivers/8255.c b/comedi/drivers/8255.c index aa165913..78f784f9 100644 --- a/comedi/drivers/8255.c +++ b/comedi/drivers/8255.c @@ -167,7 +167,6 @@ int subdev_8255_init(comedi_device *dev,comedi_subdevice *s,int (*cb)(int,int,in s->range_table=&range_digital; s->maxdata=1; - /* XXX This causes a memory leak */ s->private=kmalloc(sizeof(struct subdev_8255_struct),GFP_KERNEL); if(!s->private)return -ENOMEM; @@ -183,11 +182,15 @@ int subdev_8255_init(comedi_device *dev,comedi_subdevice *s,int (*cb)(int,int,in s->state=0; s->io_bits=0; do_config(dev,s); - return 0; } +void subdev_8255_cleanup(comedi_device *dev,comedi_subdevice *s) +{ + if(s->private) + kfree(s->private); +} /* @@ -251,6 +254,7 @@ static int dev_8255_detach(comedi_device *dev) iobase=(int)CALLBACK_ARG; release_region(iobase,_8255_SIZE); } + subdev_8255_cleanup(dev,s); } return 0; diff --git a/comedi/drivers/8255.h b/comedi/drivers/8255.h index f69b285b..c200b05d 100644 --- a/comedi/drivers/8255.h +++ b/comedi/drivers/8255.h @@ -26,15 +26,10 @@ #include -#ifdef CONFIG_COMEDI_8255 - -int subdev_8255_init(comedi_device *dev,comedi_subdevice *s,int (*cb)(int,int,int,void *),void *arg); - -#else - -#ifdef CONFIG_COMEDI_8255_MODULE +#if defined(CONFIG_COMEDI_8255) || defined(CONFIG_COMEDI_8255_MODULE) int subdev_8255_init(comedi_device *dev,comedi_subdevice *s,int (*cb)(int,int,int,void *),void *arg); +void subdev_8255_cleanup(comedi_device *dev,comedi_subdevice *s); #else @@ -47,7 +42,7 @@ static inline int subdev_8255_init(comedi_device *dev,comedi_subdevice *s,void * return 0; } -#endif +static inline void subdev_8255_cleanup(comedi_device *dev,comedi_subdevice *s){} #endif diff --git a/comedi/drivers/adl_pci9118.c b/comedi/drivers/adl_pci9118.c index 9af5df16..3d956282 100644 --- a/comedi/drivers/adl_pci9118.c +++ b/comedi/drivers/adl_pci9118.c @@ -1185,9 +1185,9 @@ static int pci9118_attach(comedi_device *dev,comedi_devconfig *it) return -EIO; } - dev->iobase=iobase_9; - request_region(dev->iobase, this_board->iorange_9118, "ADLink PCI-9118"); + request_region(iobase_9, this_board->iorange_9118, "ADLink PCI-9118"); + dev->iobase=iobase_9; dev->board_name = this_board->name; if((ret=alloc_private(dev,sizeof(pci9118_private)))<0) @@ -1195,8 +1195,8 @@ static int pci9118_attach(comedi_device *dev,comedi_devconfig *it) devpriv->amcc=card; devpriv->master=master; + request_region(iobase_a, this_board->iorange_amcc, "ADLink PCI-9118"); devpriv->iobase_a=iobase_a; - request_region(devpriv->iobase_a, this_board->iorange_amcc, "ADLink PCI-9118"); if (irq>0) { if (comedi_request_irq(irq, interrupt_pci9118, SA_SHIRQ, "ADLink PCI-9118", dev)) { diff --git a/comedi/drivers/comedi_parport.c b/comedi/drivers/comedi_parport.c index fcf2807f..bd38b3f8 100644 --- a/comedi/drivers/comedi_parport.c +++ b/comedi/drivers/comedi_parport.c @@ -129,23 +129,23 @@ static int parport_intr_cmdtest(comedi_device *dev,comedi_subdevice *s, tmp=cmd->start_src; cmd->start_src &= TRIG_NOW; - if(!cmd->start_src && tmp!=cmd->start_src)err++; + if(!cmd->start_src || tmp!=cmd->start_src)err++; tmp=cmd->scan_begin_src; cmd->scan_begin_src &= TRIG_EXT; - if(!cmd->scan_begin_src && tmp!=cmd->scan_begin_src)err++; + if(!cmd->scan_begin_src || tmp!=cmd->scan_begin_src)err++; tmp=cmd->convert_src; cmd->convert_src &= TRIG_FOLLOW; - if(!cmd->convert_src && tmp!=cmd->convert_src)err++; + if(!cmd->convert_src || tmp!=cmd->convert_src)err++; tmp=cmd->scan_end_src; cmd->scan_end_src &= TRIG_COUNT; - if(!cmd->scan_end_src && tmp!=cmd->scan_end_src)err++; + if(!cmd->scan_end_src || tmp!=cmd->scan_end_src)err++; tmp=cmd->stop_src; cmd->stop_src &= TRIG_NONE; - if(!cmd->stop_src && tmp!=cmd->stop_src)err++; + if(!cmd->stop_src || tmp!=cmd->stop_src)err++; if(err)return 1; diff --git a/comedi/drivers/comedi_rt_timer.c b/comedi/drivers/comedi_rt_timer.c index dcd57d27..8c13d5a3 100644 --- a/comedi/drivers/comedi_rt_timer.c +++ b/comedi/drivers/comedi_rt_timer.c @@ -95,7 +95,7 @@ static inline RTIME nano2count(long long ns) static int timer_attach(comedi_device *dev,comedi_devconfig *it); static int timer_detach(comedi_device *dev); -static comedi_driver driver_timer={ +comedi_driver driver_timer={ module: THIS_MODULE, driver_name: "comedi_rt_timer", attach: timer_attach, @@ -374,9 +374,6 @@ static int timer_cmd(comedi_device *dev,comedi_subdevice *s) comedi_error(dev, "failed to obtain lock"); return ret; } -#ifdef CONFIG_COMEDI_RTAI - start_rt_timer(1); -#endif delay = nano2count(cmd->start_arg); if(cmd->scan_begin_src == TRIG_TIMER) period = nano2count(cmd->scan_begin_arg); @@ -386,6 +383,9 @@ static int timer_cmd(comedi_device *dev,comedi_subdevice *s) comedi_error(dev, "bug!"); return -1; } +#ifdef CONFIG_COMEDI_RTAI + start_rt_timer(period); +#endif if(s == dev->read_subdev) ret = rt_task_init(&devpriv->rt_task,timer_ai_task_func,(int)dev,3000,0,0,0); else diff --git a/comedi/drivers/daqboard2000.c b/comedi/drivers/daqboard2000.c index 0aa61dfa..bef7ea3f 100644 --- a/comedi/drivers/daqboard2000.c +++ b/comedi/drivers/daqboard2000.c @@ -288,7 +288,6 @@ typedef struct daqboard2000_hw { -static void daqboard2000_release_resources(comedi_device * dev); static int daqboard2000_attach(comedi_device *dev,comedi_devconfig *it); static int daqboard2000_detach(comedi_device *dev); @@ -316,6 +315,7 @@ typedef struct { } card; void *daq; void *plx; + lsampl_t ao_readback[2]; } daqboard2000_private; #define devpriv ((daqboard2000_private*)dev->private) @@ -362,35 +362,40 @@ static void setup_sampling(comedi_device *dev, int chan, int gain) } -static int daqboard2000_ai(comedi_device *dev, comedi_subdevice *s, - comedi_trig *it) +static int daqboard2000_ai_insn_read(comedi_device *dev, comedi_subdevice *s, + comedi_insn *insn, lsampl_t *data) { int i; daqboard2000_hw *fpga = devpriv->daq; + int gain, chan, timeout; fpga->acqControl = DAQBOARD2000_AcqResetScanListFifo; - fpga->acqControl = DAQBOARD2000_AcqResetResultsFifo | DAQBOARD2000_AcqResetConfigPipe; - for(i=0 ; i < it->n_chan ; i++) { - int gain, chan, timeout; + fpga->acqControl = DAQBOARD2000_AcqResetResultsFifo | DAQBOARD2000_AcqResetConfigPipe; - gain = CR_RANGE(it->chanlist[i]); - chan = CR_CHAN(it->chanlist[i]); + gain = CR_RANGE(insn->chanspec); + chan = CR_CHAN(insn->chanspec); + + /* This doesn't look efficient. I decided to take the conservative + * approach when I did the insn conversion. Perhaps it would be + * better to have broken it completely, then someone would have been + * forced to fix it. --ds */ + for(i=0;in;i++){ setup_sampling(dev, chan, gain); fpga->acqControl = DAQBOARD2000_SeqStartScanList; for (timeout = 0 ; timeout < 20 ; timeout++) { if (fpga->acqControl & DAQBOARD2000_AcqConfigPipeFull) { break; } - udelay(2); + //udelay(2); } fpga->acqControl = DAQBOARD2000_AdcPacerEnable; for (timeout = 0 ; timeout < 20 ; timeout++) { if (fpga->acqControl & DAQBOARD2000_AcqLogicScanning) { break; } - udelay(2); + //udelay(2); } for (timeout = 0 ; timeout < 20 ; timeout++) { if (fpga->acqControl & DAQBOARD2000_AcqResultsFIFOHasValidData) { break;} - udelay(2); + //udelay(2); } - it->data[i] = fpga->acqResultsFIFO; + data[i] = fpga->acqResultsFIFO; fpga->acqControl = DAQBOARD2000_AdcPacerDisable; fpga->acqControl = DAQBOARD2000_SeqStopScanList; } @@ -398,33 +403,46 @@ static int daqboard2000_ai(comedi_device *dev, comedi_subdevice *s, return i; } -static int daqboard2000_ao(comedi_device *dev, comedi_subdevice *s, - comedi_trig *it) + +static int daqboard2000_ao_insn_read(comedi_device *dev, comedi_subdevice *s, + comedi_insn *insn, lsampl_t *data) { int i; - daqboard2000_hw *fpga = devpriv->daq; + int chan = CR_CHAN(insn->chanspec); - for(i=0 ; i < it->n_chan ; i++) { - int chan, data, timeout; + for(i=0;in;i++){ + data[i]=devpriv->ao_readback[chan]; + } - chan = CR_CHAN(it->chanlist[i]); - data = it->data[i]; -/* - OK, since it works OK without enabling the DAC's, let's keep - it as simple as possible... - fpga->dacControl = (chan + 2) * 0x0010 | 0x0001; udelay(1000); -*/ - fpga->dacSetting[chan] = data; + return i; +} + +static int daqboard2000_ao_insn_write(comedi_device *dev, comedi_subdevice *s, + comedi_insn *insn, lsampl_t *data) +{ + int i; + int chan = CR_CHAN(insn->chanspec); + daqboard2000_hw *fpga = devpriv->daq; + int timeout; + + for(i=0;in;i++){ + /* + * OK, since it works OK without enabling the DAC's, let's keep + * it as simple as possible... + */ + //fpga->dacControl = (chan + 2) * 0x0010 | 0x0001; udelay(1000); + fpga->dacSetting[chan] = data[i]; for (timeout = 0 ; timeout < 20 ; timeout++) { if ((fpga->dacControl & ((chan + 1) * 0x0010)) == 0) { break; } - udelay(2); + //udelay(2); } -/* - Since we never enabled the DAC's, we don't need to disable it... - fpga->dacControl = (chan + 2) * 0x0010 | 0x0000; udelay(1000); -*/ - + devpriv->ao_readback[chan] = data[i]; + /* + * Since we never enabled the DAC's, we don't need to disable it... + * fpga->dacControl = (chan + 2) * 0x0010 | 0x0000; udelay(1000); + */ } + return i; } @@ -756,7 +774,7 @@ static int daqboard2000_attach(comedi_device *dev, comedi_devconfig *it) s->subdev_flags = SDF_READABLE|SDF_RT; s->n_chan = 24; s->maxdata = 0xffff; - s->trig[0] = daqboard2000_ai; + s->insn_read = daqboard2000_ai_insn_read; s->range_table = &range_daqboard2000_ai; s = dev->subdevices + 1; @@ -765,7 +783,8 @@ static int daqboard2000_attach(comedi_device *dev, comedi_devconfig *it) s->subdev_flags = SDF_WRITEABLE|SDF_RT; s->n_chan = 2; s->maxdata = 0xffff; - s->trig[0] = daqboard2000_ao; + s->insn_read = daqboard2000_ao_insn_read; + s->insn_write = daqboard2000_ao_insn_write; s->range_table = &range_daqboard2000_ao; s = dev->subdevices + 2; @@ -777,8 +796,13 @@ out: return result; } -static void daqboard2000_release_resources(comedi_device * dev) +static int daqboard2000_detach(comedi_device * dev) { + printk("comedi%d: daqboard2000: remove\n", dev->minor); + + if(dev->subdevices) + subdev_8255_cleanup(dev,dev->subdevices+2); + if (devpriv && devpriv->daq) { iounmap(devpriv->daq); } @@ -788,12 +812,6 @@ static void daqboard2000_release_resources(comedi_device * dev) if (dev->irq) { free_irq(dev->irq, dev); } -} - -static int daqboard2000_detach(comedi_device * dev) -{ - printk("comedi%d: daqboard2000: remove\n", dev->minor); - daqboard2000_release_resources(dev); return 0; } diff --git a/comedi/drivers/das08.c b/comedi/drivers/das08.c index 4b11de87..6ce8293e 100644 --- a/comedi/drivers/das08.c +++ b/comedi/drivers/das08.c @@ -498,10 +498,11 @@ static int das08_attach(comedi_device *dev,comedi_devconfig *it) { comedi_subdevice *s; int ret; + int iobase; - dev->iobase=it->options[0]; - printk("comedi%d: das08: 0x%04x",dev->minor,dev->iobase); - if(check_region(dev->iobase,DAS08_SIZE)<0){ + iobase=it->options[0]; + printk("comedi%d: das08: 0x%04x",dev->minor,iobase); + if(check_region(iobase,DAS08_SIZE)<0){ printk(" I/O port conflict\n"); return -EIO; } @@ -514,7 +515,8 @@ static int das08_attach(comedi_device *dev,comedi_devconfig *it) if((ret=alloc_private(dev,sizeof(struct das08_private_struct)))<0) return ret; - request_region(dev->iobase,DAS08_SIZE,"das08"); + request_region(iobase,DAS08_SIZE,"das08"); + dev->iobase = iobase; s=dev->subdevices+0; /* ai */ @@ -585,7 +587,11 @@ static int das08_detach(comedi_device *dev) { printk(KERN_INFO "comedi%d: das08: remove\n",dev->minor); - release_region(dev->iobase,DAS08_SIZE); + if(dev->subdevices) + subdev_8255_cleanup(dev,dev->subdevices+4); + + if(dev->iobase) + release_region(dev->iobase,DAS08_SIZE); return 0; } diff --git a/comedi/drivers/das16.c b/comedi/drivers/das16.c index f6aee000..1f5c6b0e 100644 --- a/comedi/drivers/das16.c +++ b/comedi/drivers/das16.c @@ -454,26 +454,26 @@ static int das16_cmd_test(comedi_device *dev,comedi_subdevice *s, comedi_cmd *cm /* make sure triggers are valid */ tmp=cmd->start_src; cmd->start_src &= TRIG_NOW; - if(!cmd->start_src && tmp!=cmd->start_src)err++; + if(!cmd->start_src || tmp!=cmd->start_src)err++; tmp=cmd->scan_begin_src; cmd->scan_begin_src &= TRIG_FOLLOW|TRIG_TIMER; - if(!cmd->scan_begin_src && tmp!=cmd->scan_begin_src)err++; + if(!cmd->scan_begin_src || tmp!=cmd->scan_begin_src)err++; /* XXX This must be TRIG_FOLLOW until I figure out a way to * * time the individual conversions. */ tmp=cmd->convert_src; //cmd->convert_src &= TRIG_TIMER; cmd->convert_src &= TRIG_FOLLOW; - if(!cmd->convert_src && tmp!=cmd->convert_src)err++; + if(!cmd->convert_src || tmp!=cmd->convert_src)err++; tmp=cmd->scan_end_src; cmd->scan_end_src &= TRIG_COUNT; - if(!cmd->scan_end_src && tmp!=cmd->scan_end_src)err++; + if(!cmd->scan_end_src || tmp!=cmd->scan_end_src)err++; tmp=cmd->stop_src; cmd->stop_src &= TRIG_COUNT|TRIG_NONE; - if(!cmd->stop_src && tmp!=cmd->stop_src)err++; + if(!cmd->stop_src || tmp!=cmd->stop_src)err++; if(err)return 1; @@ -985,8 +985,9 @@ static int das16_attach(comedi_device *dev, comedi_devconfig *it) { comedi_subdevice *s; int ret, irq; + int iobase; - dev->iobase = it->options[0]; + iobase = it->options[0]; printk("comedi%d: das16:",dev->minor); @@ -997,25 +998,24 @@ static int das16_attach(comedi_device *dev, comedi_devconfig *it) dev->board_name = thisboard->name; if(thisboard->size<0x400){ - printk(" 0x%04x-0x%04x\n", - dev->iobase,dev->iobase+thisboard->size); - if(check_region(dev->iobase,thisboard->size)<0){ + printk(" 0x%04x-0x%04x\n", iobase, iobase+thisboard->size); + if(check_region(iobase,thisboard->size)<0){ printk(" I/O port conflict\n"); return -EIO; } }else{ printk(" 0x%04x-0x%04x 0x%04x-0x%04x\n", - dev->iobase,dev->iobase+0x0f, - dev->iobase+0x400,dev->iobase+0x400+(thisboard->size&0x3ff)); - if(check_region(dev->iobase,0x10) < 0) { + iobase,iobase+0x0f, + iobase+0x400,iobase+0x400+(thisboard->size&0x3ff)); + if(check_region(iobase,0x10) < 0) { printk(" I/O port conflict: 0x%04x-0x%04x\n", - dev->iobase,dev->iobase+0x0f); + iobase,iobase+0x0f); return -EIO; } - if(check_region(dev->iobase+0x400,thisboard->size&0x3ff)<0){ + if(check_region(iobase+0x400,thisboard->size&0x3ff)<0){ printk(" I/O port conflict: 0x%04x-0x%04x\n", - dev->iobase+0x400, - dev->iobase+0x400+(thisboard->size&0x3ff)); + iobase+0x400, + iobase+0x400+(thisboard->size&0x3ff)); return -EIO; } } @@ -1025,12 +1025,14 @@ static int das16_attach(comedi_device *dev, comedi_devconfig *it) return ret; if(thisboard->size<0x400){ - request_region(dev->iobase,thisboard->size,"das16"); + request_region(iobase,thisboard->size,"das16"); }else{ - request_region(dev->iobase,0x10,"das16"); - request_region(dev->iobase+0x400,thisboard->size&0x3ff,"das16"); + request_region(iobase,0x10,"das16"); + request_region(iobase+0x400,thisboard->size&0x3ff,"das16"); } + dev->iobase = iobase; + /* now for the irq */ irq=it->options[1]; if(irq>0){ @@ -1134,6 +1136,9 @@ static int das16_detach(comedi_device *dev) das16_reset(dev); + if(dev->subdevices) + subdev_8255_cleanup(dev,dev->subdevices+4); + if(dev->irq) free_irq(dev->irq, dev); diff --git a/comedi/drivers/das1800.c b/comedi/drivers/das1800.c index f42f8975..34feb124 100644 --- a/comedi/drivers/das1800.c +++ b/comedi/drivers/das1800.c @@ -1121,23 +1121,23 @@ static int das1800_ai_do_cmdtest(comedi_device *dev,comedi_subdevice *s,comedi_c tmp = cmd->start_src; cmd->start_src &= TRIG_NOW | TRIG_EXT; - if(!cmd->start_src && tmp != cmd->start_src) err++; + if(!cmd->start_src || tmp != cmd->start_src) err++; tmp = cmd->scan_begin_src; cmd->scan_begin_src &= TRIG_FOLLOW | TRIG_TIMER | TRIG_EXT; - if(!cmd->scan_begin_src && tmp != cmd->scan_begin_src) err++; + if(!cmd->scan_begin_src || tmp != cmd->scan_begin_src) err++; tmp = cmd->convert_src; cmd->convert_src &= TRIG_TIMER | TRIG_EXT; - if(!cmd->convert_src && tmp != cmd->convert_src) err++; + if(!cmd->convert_src || tmp != cmd->convert_src) err++; tmp = cmd->scan_end_src; cmd->scan_end_src &= TRIG_COUNT; - if(!cmd->scan_end_src && tmp != cmd->scan_end_src) err++; + if(!cmd->scan_end_src || tmp != cmd->scan_end_src) err++; tmp=cmd->stop_src; cmd->stop_src &= TRIG_COUNT | TRIG_EXT | TRIG_NONE; - if(!cmd->stop_src && tmp != cmd->stop_src) err++; + if(!cmd->stop_src || tmp != cmd->stop_src) err++; if(err) return 1; diff --git a/comedi/drivers/das6402.c b/comedi/drivers/das6402.c index 8402318e..9d63892a 100644 --- a/comedi/drivers/das6402.c +++ b/comedi/drivers/das6402.c @@ -331,8 +331,8 @@ static int das6402_attach(comedi_device *dev,comedi_devconfig *it) printk(" I/O port conflict\n"); return -EIO; } + request_region(iobase,DAS6402_SIZE,"das6402"); dev->iobase=iobase; - request_region(dev->iobase,DAS6402_SIZE,"das6402"); /* should do a probe here */ diff --git a/comedi/drivers/das800.c b/comedi/drivers/das800.c index 9c26d7c6..424122c2 100644 --- a/comedi/drivers/das800.c +++ b/comedi/drivers/das800.c @@ -576,23 +576,23 @@ static int das800_ai_do_cmdtest(comedi_device *dev,comedi_subdevice *s,comedi_cm tmp = cmd->start_src; cmd->start_src &= TRIG_NOW | TRIG_EXT; - if(!cmd->start_src && tmp != cmd->start_src) err++; + if(!cmd->start_src || tmp != cmd->start_src) err++; tmp = cmd->scan_begin_src; cmd->scan_begin_src &= TRIG_FOLLOW; - if(!cmd->scan_begin_src && tmp != cmd->scan_begin_src) err++; + if(!cmd->scan_begin_src || tmp != cmd->scan_begin_src) err++; tmp = cmd->convert_src; cmd->convert_src &= TRIG_TIMER | TRIG_EXT; - if(!cmd->convert_src && tmp != cmd->convert_src) err++; + if(!cmd->convert_src || tmp != cmd->convert_src) err++; tmp = cmd->scan_end_src; cmd->scan_end_src &= TRIG_COUNT; - if(!cmd->scan_end_src && tmp != cmd->scan_end_src) err++; + if(!cmd->scan_end_src || tmp != cmd->scan_end_src) err++; tmp=cmd->stop_src; cmd->stop_src &= TRIG_COUNT | TRIG_NONE; - if(!cmd->stop_src && tmp!=cmd->stop_src) err++; + if(!cmd->stop_src || tmp!=cmd->stop_src) err++; if(err) return 1; diff --git a/comedi/drivers/dt2814.c b/comedi/drivers/dt2814.c index 21a560c4..c1091b78 100644 --- a/comedi/drivers/dt2814.c +++ b/comedi/drivers/dt2814.c @@ -135,23 +135,23 @@ static int dt2814_ai_cmdtest(comedi_device *dev,comedi_subdevice *s, tmp=cmd->start_src; cmd->start_src &= TRIG_NOW; - if(!cmd->start_src && tmp!=cmd->start_src)err++; + if(!cmd->start_src || tmp!=cmd->start_src)err++; tmp=cmd->scan_begin_src; cmd->scan_begin_src &= TRIG_TIMER; - if(!cmd->scan_begin_src && tmp!=cmd->scan_begin_src)err++; + if(!cmd->scan_begin_src || tmp!=cmd->scan_begin_src)err++; tmp=cmd->convert_src; cmd->convert_src &= TRIG_NOW; - if(!cmd->convert_src && tmp!=cmd->convert_src)err++; + if(!cmd->convert_src || tmp!=cmd->convert_src)err++; tmp=cmd->scan_end_src; cmd->scan_end_src &= TRIG_COUNT; - if(!cmd->scan_end_src && tmp!=cmd->scan_end_src)err++; + if(!cmd->scan_end_src || tmp!=cmd->scan_end_src)err++; tmp=cmd->stop_src; cmd->stop_src &= TRIG_COUNT|TRIG_NONE; - if(!cmd->stop_src && tmp!=cmd->stop_src)err++; + if(!cmd->stop_src || tmp!=cmd->stop_src)err++; if(err)return 1; diff --git a/comedi/drivers/dt282x.c b/comedi/drivers/dt282x.c index 579bdcd5..c5215efd 100644 --- a/comedi/drivers/dt282x.c +++ b/comedi/drivers/dt282x.c @@ -692,23 +692,23 @@ static int dt282x_ai_cmdtest(comedi_device * dev, comedi_subdevice * s,comedi_cm tmp=cmd->start_src; cmd->start_src &= TRIG_NOW; - if(!cmd->start_src && tmp!=cmd->start_src)err++; + if(!cmd->start_src || tmp!=cmd->start_src)err++; tmp=cmd->scan_begin_src; cmd->scan_begin_src &= TRIG_FOLLOW|TRIG_EXT; - if(!cmd->scan_begin_src && tmp!=cmd->scan_begin_src)err++; + if(!cmd->scan_begin_src || tmp!=cmd->scan_begin_src)err++; tmp=cmd->convert_src; cmd->convert_src &= TRIG_TIMER; - if(!cmd->convert_src && tmp!=cmd->convert_src)err++; + if(!cmd->convert_src || tmp!=cmd->convert_src)err++; tmp=cmd->scan_end_src; cmd->scan_end_src &= TRIG_COUNT; - if(!cmd->scan_end_src && tmp!=cmd->scan_end_src)err++; + if(!cmd->scan_end_src || tmp!=cmd->scan_end_src)err++; tmp=cmd->stop_src; cmd->stop_src &= TRIG_COUNT|TRIG_NONE; - if(!cmd->stop_src && tmp!=cmd->stop_src)err++; + if(!cmd->stop_src || tmp!=cmd->stop_src)err++; if(err)return 1; @@ -934,24 +934,24 @@ static int dt282x_ao_cmdtest(comedi_device *dev,comedi_subdevice *s,comedi_cmd * tmp=cmd->start_src; cmd->start_src &= TRIG_NOW; - if(!cmd->start_src && tmp!=cmd->start_src)err++; + if(!cmd->start_src || tmp!=cmd->start_src)err++; tmp=cmd->scan_begin_src; cmd->scan_begin_src &= TRIG_TIMER; - if(!cmd->scan_begin_src && tmp!=cmd->scan_begin_src)err++; + if(!cmd->scan_begin_src || tmp!=cmd->scan_begin_src)err++; tmp=cmd->convert_src; cmd->convert_src &= TRIG_NOW; - if(!cmd->convert_src && tmp!=cmd->convert_src)err++; + if(!cmd->convert_src || tmp!=cmd->convert_src)err++; tmp=cmd->scan_end_src; cmd->scan_end_src &= TRIG_COUNT; - if(!cmd->scan_end_src && tmp!=cmd->scan_end_src)err++; + if(!cmd->scan_end_src || tmp!=cmd->scan_end_src)err++; tmp=cmd->stop_src; //cmd->stop_src &= TRIG_COUNT|TRIG_NONE; cmd->stop_src &= TRIG_COUNT; /* XXX */ - if(!cmd->stop_src && tmp!=cmd->stop_src)err++; + if(!cmd->stop_src || tmp!=cmd->stop_src)err++; if(err)return 1; diff --git a/comedi/drivers/fl512.c b/comedi/drivers/fl512.c index b70764bf..9716ee14 100644 --- a/comedi/drivers/fl512.c +++ b/comedi/drivers/fl512.c @@ -132,16 +132,18 @@ static int fl512_ao_insn_readback(comedi_device *dev, */ static int fl512_attach(comedi_device *dev,comedi_devconfig *it) { + int iobase; comedi_subdevice *s; /* pointer to the subdevice: Analog in, Analog out, ( not made ->and Digital IO) */ - dev->iobase = it->options[0]; - printk("comedi:%d fl512: 0x%04x",dev->minor,dev->iobase); - if (check_region(dev->iobase, FL512_SIZE) < 0) { + iobase = it->options[0]; + printk("comedi:%d fl512: 0x%04x",dev->minor,iobase); + if (check_region(iobase, FL512_SIZE) < 0) { printk(" I/O port conflict\n"); return -EIO; } - request_region(dev->iobase, FL512_SIZE, "fl512"); + request_region(iobase, FL512_SIZE, "fl512"); + dev->iobase = iobase; dev->board_name = "fl512"; dev->n_subdevices = 2; /* Analog in/out */ if(alloc_private(dev,sizeof(fl512_private)) < 0) diff --git a/comedi/drivers/multiq3.c b/comedi/drivers/multiq3.c index 84787038..9a9e30e2 100644 --- a/comedi/drivers/multiq3.c +++ b/comedi/drivers/multiq3.c @@ -94,74 +94,95 @@ comedi_driver driver_multiq3={ detach: multiq3_detach, }; +struct multiq3_private{ + lsampl_t ao_readback[2]; +}; +#define devpriv ((struct multiq3_private *)dev->private) -static int multiq3_ai(comedi_device *dev, comedi_subdevice *s, comedi_trig *it) +static int multiq3_ai_insn_read(comedi_device *dev,comedi_subdevice *s, + comedi_insn *insn, lsampl_t *data) { - int i, hi, lo; - int chan; - int data; - int status, control; + int i,n; + int chan; + unsigned int hi, lo; - chan = CR_CHAN(it->chanlist[0]); - control = MULTIQ3_CONTROL_MUST | MULTIQ3_AD_MUX_EN | (chan<<3); - outw(control, dev->iobase+MULTIQ3_CONTROL); - for (i = 0; i < MULTIQ3_TIMEOUT; i++) { - status = inw(dev->iobase+MULTIQ3_STATUS); - if(status & MULTIQ3_STATUS_EOC) { - break; - } - udelay(10); - } - if(i == MULTIQ3_TIMEOUT){ - rt_printk("multiq3: timeout\n"); - return -ETIME; - } - outw(0, dev->iobase+MULTIQ3_AD_CS); - for (i = 0; i < MULTIQ3_TIMEOUT; i++) { - status = inw(dev->iobase+MULTIQ3_STATUS); - if(status & MULTIQ3_STATUS_EOC_I) { - break; - } - udelay(10); - } - hi = inb(dev->iobase + MULTIQ3_AD_CS) &0xff; - lo = inb(dev->iobase + MULTIQ3_AD_CS) &0xff; + chan = CR_CHAN(insn->chanspec); + outw(MULTIQ3_CONTROL_MUST | MULTIQ3_AD_MUX_EN | (chan<<3), + dev->iobase+MULTIQ3_CONTROL); + + for(i = 0; i < MULTIQ3_TIMEOUT; i++) { + if(inw(dev->iobase+MULTIQ3_STATUS) & MULTIQ3_STATUS_EOC) + break; + } + if(i==MULTIQ3_TIMEOUT)return -ETIMEDOUT; + + for(n=0;nn;n++){ + outw(0, dev->iobase+MULTIQ3_AD_CS); + for(i = 0; i < MULTIQ3_TIMEOUT; i++) { + if(inw(dev->iobase+MULTIQ3_STATUS) & MULTIQ3_STATUS_EOC_I) + break; + } + if(i==MULTIQ3_TIMEOUT)return -ETIMEDOUT; + + hi = inb(dev->iobase + MULTIQ3_AD_CS); + lo = inb(dev->iobase + MULTIQ3_AD_CS); + data[n] = ((hi << 8) | lo) & 0xfff; + } + + return i; +} - data = (((hi << 8) | lo) + 0x1000) & 0x1fff; - it->data[0]=data; +static int multiq3_ao_insn_read(comedi_device *dev, comedi_subdevice *s, + comedi_insn *insn, lsampl_t *data) +{ + int i; + int chan = CR_CHAN(insn->chanspec); - return 1; + for(i=0;in;i++){ + data[i]=devpriv->ao_readback[chan]; + } + + return i; } -static int multiq3_ao(comedi_device *dev, comedi_subdevice *s, comedi_trig *it) +static int multiq3_ao_insn_write(comedi_device *dev, comedi_subdevice *s, + comedi_insn *insn, lsampl_t *data) { - int chan, control; + int i; + int chan = CR_CHAN(insn->chanspec); - chan=CR_CHAN(it->chanlist[0]); - control = MULTIQ3_CONTROL_MUST | MULTIQ3_DA_LOAD | chan; - outw(control, dev->iobase+MULTIQ3_CONTROL); - outw(it->data[0], dev->iobase+MULTIQ3_DAC_DATA); - control = MULTIQ3_CONTROL_MUST; - outw(control, dev->iobase+MULTIQ3_CONTROL); - return 1; + for(i=0;in;i++){ + outw(MULTIQ3_CONTROL_MUST | MULTIQ3_DA_LOAD | chan, + dev->iobase+MULTIQ3_CONTROL); + outw(data[i], dev->iobase+MULTIQ3_DAC_DATA); + outw(MULTIQ3_CONTROL_MUST, dev->iobase+MULTIQ3_CONTROL); + + devpriv->ao_readback[chan] = data[i]; + } + + return i; } -static int multiq3_di(comedi_device *dev, comedi_subdevice *s, comedi_trig *it) +static int multiq3_di_insn_bits(comedi_device *dev, comedi_subdevice *s, + comedi_insn *insn, lsampl_t *data) { - unsigned int bits; + if(insn->n!=2)return -EINVAL; - bits = inw(dev->iobase + MULTIQ3_DIGIN_PORT); + data[1] = inw(dev->iobase + MULTIQ3_DIGIN_PORT); - return di_unpack(bits,it); + return 2; } -static int multiq3_do(comedi_device *dev, comedi_subdevice *s, comedi_trig *it) +static int multiq3_do_insn_bits(comedi_device *dev, comedi_subdevice *s, + comedi_insn *insn, lsampl_t *data) { - do_pack(&s->state,it); + if(insn->n!=2)return -EINVAL; + s->state &= ~data[0]; + s->state |= (data[0]&data[1]); outw(s->state, dev->iobase + MULTIQ3_DIGOUT_PORT); - return it->n_chan; + return 2; } static int multiq3_ei(comedi_device *dev, comedi_subdevice *s, comedi_trig *it) @@ -235,12 +256,15 @@ static int multiq3_attach(comedi_device * dev, comedi_devconfig * it) result = alloc_subdevices(dev); if(result<0)return result; + result = alloc_private(dev,sizeof(struct multiq3_private)); + if(result<0)return result; + s = dev->subdevices + 0; /* ai subdevice */ s->type = COMEDI_SUBD_AI; s->subdev_flags = SDF_READABLE; s->n_chan = 8; - s->trig[0] = multiq3_ai; + s->insn_read = multiq3_ai_insn_read; s->maxdata = 0x1fff; s->range_table = &range_bipolar5; @@ -249,7 +273,8 @@ static int multiq3_attach(comedi_device * dev, comedi_devconfig * it) s->type = COMEDI_SUBD_AO; s->subdev_flags = SDF_WRITEABLE; s->n_chan = 8; - s->trig[0] = multiq3_ao; + s->insn_read = multiq3_ao_insn_read; + s->insn_write = multiq3_ao_insn_write; s->maxdata = 0xfff; s->range_table = &range_bipolar5; @@ -258,7 +283,7 @@ static int multiq3_attach(comedi_device * dev, comedi_devconfig * it) s->type = COMEDI_SUBD_DI; s->subdev_flags = SDF_READABLE; s->n_chan = 16; - s->trig[0] = multiq3_di; + s->insn_bits = multiq3_di_insn_bits; s->maxdata = 1; s->range_table = &range_digital; @@ -267,7 +292,7 @@ static int multiq3_attach(comedi_device * dev, comedi_devconfig * it) s->type = COMEDI_SUBD_DO; s->subdev_flags = SDF_WRITEABLE; s->n_chan = 16; - s->trig[0] = multiq3_do; + s->insn_bits = multiq3_do_insn_bits; s->maxdata = 1; s->range_table = &range_digital; s->state = 0; diff --git a/comedi/drivers/ni_atmio.c b/comedi/drivers/ni_atmio.c index 59e4b9ce..473b12eb 100644 --- a/comedi/drivers/ni_atmio.c +++ b/comedi/drivers/ni_atmio.c @@ -273,6 +273,8 @@ static int ni_getboardtype(comedi_device *dev); /* clean up allocated resources */ static int ni_atmio_detach(comedi_device *dev) { + mio_common_detach(dev); + #ifdef HAVE_ISAPNP if(devpriv->pcidev) devpriv->pcidev->deactivate(devpriv->pcidev); diff --git a/comedi/drivers/ni_atmio16d.c b/comedi/drivers/ni_atmio16d.c index 9f1b047e..1f36ed1a 100644 --- a/comedi/drivers/ni_atmio16d.c +++ b/comedi/drivers/ni_atmio16d.c @@ -287,23 +287,23 @@ static int atmio16d_ai_cmdtest(comedi_device *dev, comedi_subdevice *s, comedi_c /* make sure triggers are valid */ tmp=cmd->start_src; cmd->start_src &= TRIG_NOW; - if(!cmd->start_src && tmp!=cmd->start_src)err++; + if(!cmd->start_src || tmp!=cmd->start_src)err++; tmp=cmd->scan_begin_src; cmd->scan_begin_src &= TRIG_FOLLOW|TRIG_TIMER; - if(!cmd->scan_begin_src && tmp!=cmd->scan_begin_src)err++; + if(!cmd->scan_begin_src || tmp!=cmd->scan_begin_src)err++; tmp=cmd->convert_src; cmd->convert_src &= TRIG_TIMER; - if(!cmd->convert_src && tmp!=cmd->convert_src)err++; + if(!cmd->convert_src || tmp!=cmd->convert_src)err++; tmp=cmd->scan_end_src; cmd->scan_end_src &= TRIG_COUNT; - if(!cmd->scan_end_src && tmp!=cmd->scan_end_src)err++; + if(!cmd->scan_end_src || tmp!=cmd->scan_end_src)err++; tmp=cmd->stop_src; cmd->stop_src &= TRIG_COUNT|TRIG_NONE; - if(!cmd->stop_src && tmp!=cmd->stop_src)err++; + if(!cmd->stop_src || tmp!=cmd->stop_src)err++; if(err)return 1; @@ -621,40 +621,40 @@ static int atmio16d_ao(comedi_device * dev, comedi_subdevice *s, comedi_trig * i } -static int atmio16d_dio(comedi_device * dev, comedi_subdevice *s, comedi_trig * it) +static int atmio16d_dio_insn_bits(comedi_device *dev, comedi_subdevice *s, + comedi_insn *insn, lsampl_t *data) { - unsigned int data,mask; - int i; + if(insn->n!=2)return -EINVAL; -#ifdef DEBUG1 - printk("atmio16d_dio\n"); -#endif + if(data[0]){ + s->state &= ~data[0]; + s->state |= (data[0]|data[1]); + outw(s->state, dev->iobase+MIO_16_DIG_OUT_REG ); + } + data[1] = inw(dev->iobase+MIO_16_DIG_IN_REG); - if(it->flags & TRIG_CONFIG){ - data = s->io_bits; - for(i=0;in_chan;i++){ - mask=(CR_CHAN(it->chanlist[i])<4)?0x0f:0xf0; - data &= ~mask; - if(it->data[i]) - data |= mask; - } - s->io_bits=data; - devpriv->com_reg_2_state &= ~(COMREG2_DOUTEN0|COMREG2_DOUTEN1); - if(data&0x0f) - devpriv->com_reg_2_state |= COMREG2_DOUTEN0; - if(data&0xf0) - devpriv->com_reg_2_state |= COMREG2_DOUTEN1; - }else{ - if(it->flags & TRIG_WRITE){ - do_pack(&s->state,it); - outw( s->state, dev->iobase+MIO_16_DIG_OUT_REG ); - }else{ - data = inw(dev->iobase+MIO_16_DIG_IN_REG); - di_unpack(data,it); - } + return 2; +} + +static int atmio16d_dio_insn_config(comedi_device *dev, comedi_subdevice *s, + comedi_insn *insn, lsampl_t *data) +{ + int i; + int mask; + + for(i=0;in;i++){ + mask=(CR_CHAN(insn->chanspec)<4)?0x0f:0xf0; + s->io_bits &= ~mask; + if(data[i])s->io_bits |= mask; } + devpriv->com_reg_2_state &= ~(COMREG2_DOUTEN0|COMREG2_DOUTEN1); + if(s->io_bits&0x0f) + devpriv->com_reg_2_state |= COMREG2_DOUTEN0; + if(s->io_bits&0xf0) + devpriv->com_reg_2_state |= COMREG2_DOUTEN1; + outw(devpriv->com_reg_2_state, dev->iobase+COM_REG_2); - return it->n_chan; + return i; } @@ -806,7 +806,8 @@ static int atmio16d_attach(comedi_device * dev, comedi_devconfig * it) s->type=COMEDI_SUBD_DIO; s->subdev_flags=SDF_WRITEABLE|SDF_READABLE; s->n_chan=8; - s->trig[0]=atmio16d_dio; + s->insn_bits = atmio16d_dio_insn_bits; + s->insn_config = atmio16d_dio_insn_config; s->maxdata=1; s->range_table=&range_digital; @@ -840,6 +841,9 @@ static int atmio16d_detach(comedi_device * dev) { printk("comedi%d: atmio16d: remove\n", dev->minor); + if(dev->subdevices && boardtype->has_8255) + subdev_8255_cleanup(dev,dev->subdevices + 3); + if(dev->irq) free_irq(dev->irq,dev); diff --git a/comedi/drivers/ni_mio_common.c b/comedi/drivers/ni_mio_common.c index 84570d74..4aa4ec73 100644 --- a/comedi/drivers/ni_mio_common.c +++ b/comedi/drivers/ni_mio_common.c @@ -1829,6 +1829,11 @@ static int ni_dio_insn_bits(comedi_device *dev,comedi_subdevice *s, return 2; } +static void mio_common_detach(comedi_device *dev) +{ + if(dev->subdevices && boardtype.has_8255) + subdev_8255_cleanup(dev,dev->subdevices+3); +} static int ni_E_init(comedi_device *dev,comedi_devconfig *it) { @@ -1847,7 +1852,7 @@ static int ni_E_init(comedi_device *dev,comedi_devconfig *it) s->subdev_flags=SDF_READABLE|SDF_RT|SDF_GROUND|SDF_COMMON|SDF_DIFF|SDF_OTHER; s->subdev_flags|=SDF_DITHER; s->n_chan=boardtype.n_adchan; - s->len_chanlist=512; /* XXX is this the same for PCI-MIO ? */ + s->len_chanlist=512; s->maxdata=(1<range_table=ni_range_lkup[boardtype.gainlkup]; s->insn_read=ni_ai_insn_read; diff --git a/comedi/drivers/ni_pcidio.c b/comedi/drivers/ni_pcidio.c index a75c7fd0..ec0f2803 100644 --- a/comedi/drivers/ni_pcidio.c +++ b/comedi/drivers/ni_pcidio.c @@ -452,6 +452,14 @@ static int nidio_attach(comedi_device *dev,comedi_devconfig *it) static int nidio_detach(comedi_device *dev) { + int i; + + if(!this_board->is_diodaq){ + for(i=0;in_8255;i++){ + subdev_8255_cleanup(dev,dev->subdevices+i); + } + } + if(dev->irq) comedi_free_irq(dev->irq,dev); diff --git a/comedi/drivers/ni_pcimio.c b/comedi/drivers/ni_pcimio.c index 6c8280da..a60cdea5 100644 --- a/comedi/drivers/ni_pcimio.c +++ b/comedi/drivers/ni_pcimio.c @@ -536,6 +536,8 @@ static int pcimio_find_device(comedi_device *dev,int bus,int slot); /* cleans up allocated resources */ static int pcimio_detach(comedi_device *dev) { + mio_common_detach(dev); + if(dev->private && devpriv->mite) mite_unsetup(devpriv->mite); diff --git a/comedi/drivers/pcl711.c b/comedi/drivers/pcl711.c index 0c47114f..319eac56 100644 --- a/comedi/drivers/pcl711.c +++ b/comedi/drivers/pcl711.c @@ -421,7 +421,7 @@ static int pcl711_attach(comedi_device * dev, comedi_devconfig * it) printk("I/O port conflict\n"); return -EIO; } - request_region(dev->iobase, PCL711_SIZE, "pcl711"); + request_region(iobase, PCL711_SIZE, "pcl711"); dev->iobase = iobase; /* there should be a sanity check here */ diff --git a/comedi/drivers/pcl724.c b/comedi/drivers/pcl724.c index 08f17e85..8374fd06 100644 --- a/comedi/drivers/pcl724.c +++ b/comedi/drivers/pcl724.c @@ -180,8 +180,14 @@ static int pcl724_attach(comedi_device *dev,comedi_devconfig *it) static int pcl724_detach(comedi_device *dev) { + int i; + // printk("comedi%d: pcl724: remove\n",dev->minor); + for(i=0;in_subdevices;i++){ + subdev_8255_cleanup(dev,dev->subdevices+i); + } + #ifdef PCL724_IRQ if(dev->irq){ free_irq(dev->irq,dev); diff --git a/comedi/drivers/rti802.c b/comedi/drivers/rti802.c index b669eed9..cc23c2af 100644 --- a/comedi/drivers/rti802.c +++ b/comedi/drivers/rti802.c @@ -105,14 +105,16 @@ static int rti802_attach(comedi_device * dev, comedi_devconfig * it) { comedi_subdevice *s; int i; + int iobase; - dev->iobase = it->options[0]; - printk("comedi%d: rti802: 0x%04x ", dev->minor, dev->iobase); - if (check_region(dev->iobase, RTI802_SIZE) < 0) { + iobase = it->options[0]; + printk("comedi%d: rti802: 0x%04x ", dev->minor, iobase); + if (check_region(iobase, RTI802_SIZE) < 0) { printk("I/O port conflict\n"); return -EIO; } - request_region(dev->iobase, RTI802_SIZE, "rti802"); + request_region(iobase, RTI802_SIZE, "rti802"); + dev->iobase = iobase; dev->board_name = "rti802"; diff --git a/comedi/drivers/skel.c b/comedi/drivers/skel.c index d74b0df1..bb46e7cb 100644 --- a/comedi/drivers/skel.c +++ b/comedi/drivers/skel.c @@ -242,8 +242,9 @@ static int skel_detach(comedi_device *dev) */ static int skel_ai_rinsn(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data) { - int n; + int n,i; unsigned int d; + unsigned int status; /* a typical programming sequence */ @@ -257,8 +258,19 @@ static int skel_ai_rinsn(comedi_device *dev,comedi_subdevice *s,comedi_insn *ins /* trigger conversion */ //outw(0,dev->iobase + SKEL_CONVERT); +#define TIMEOUT 100 /* wait for conversion to end */ - /* return -ETIMEDOUT if there is a timeout */ + for(i=0;iiobase + SKEL_STATUS); + if(status)break; + } + if(i==TIMEOUT){ + /* rt_printk() should be used instead of printk() + * whenever the code can be called from real-time. */ + rt_printk("timeout\n"); + return -ETIMEDOUT; + } /* read data */ //d = inw(dev->iobase + SKEL_AI_DATA); @@ -291,23 +303,23 @@ static int skel_ai_cmdtest(comedi_device *dev,comedi_subdevice *s, tmp=cmd->start_src; cmd->start_src &= TRIG_NOW; - if(!cmd->start_src && tmp!=cmd->start_src)err++; + if(!cmd->start_src || tmp!=cmd->start_src)err++; tmp=cmd->scan_begin_src; cmd->scan_begin_src &= TRIG_TIMER|TRIG_EXT; - if(!cmd->scan_begin_src && tmp!=cmd->scan_begin_src)err++; + if(!cmd->scan_begin_src || tmp!=cmd->scan_begin_src)err++; tmp=cmd->convert_src; cmd->convert_src &= TRIG_TIMER|TRIG_EXT; - if(!cmd->convert_src && tmp!=cmd->convert_src)err++; + if(!cmd->convert_src || tmp!=cmd->convert_src)err++; tmp=cmd->scan_end_src; cmd->scan_end_src &= TRIG_COUNT; - if(!cmd->scan_end_src && tmp!=cmd->scan_end_src)err++; + if(!cmd->scan_end_src || tmp!=cmd->scan_end_src)err++; tmp=cmd->stop_src; cmd->stop_src &= TRIG_COUNT|TRIG_NONE; - if(!cmd->stop_src && tmp!=cmd->stop_src)err++; + if(!cmd->stop_src || tmp!=cmd->stop_src)err++; if(err)return 1; -- 2.26.2