From: Ian Abbott Date: Thu, 15 Dec 2011 19:38:52 +0000 (+0000) Subject: das08: don't access *data when insn->n == 0 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=028143ffc7da8a4326d6e1834be3fbcf9c8897dc;p=comedi.git das08: don't access *data when insn->n == 0 Due to recent change to do_insnlist_ioctl() and do_insn_ioctl(), the 'data' pointer will be NULL when insn->n == 0. Do not access *data in this case. Also handle INSN_WRITE properly for AO subdevices. Should use the nth data value in the loop, not the 0th. Signed-off-by: Ian Abbott --- diff --git a/comedi/drivers/das08.c b/comedi/drivers/das08.c index 78b5038e..9d9e7bbb 100644 --- a/comedi/drivers/das08.c +++ b/comedi/drivers/das08.c @@ -641,12 +641,11 @@ static int das08jr_ao_winsn(comedi_device * dev, comedi_subdevice * s, int lsb, msb; int chan; - lsb = data[0] & 0xff; - msb = (data[0] >> 8) & 0xf; - chan = CR_CHAN(insn->chanspec); for (n = 0; n < insn->n; n++) { + lsb = data[n] & 0xff; + msb = (data[n] >> 8) & 0xf; #if 0 outb(lsb, dev->iobase + devpriv->ao_offset_lsb[chan]); outb(msb, dev->iobase + devpriv->ao_offset_msb[chan]); @@ -675,12 +674,11 @@ static int das08ao_ao_winsn(comedi_device * dev, comedi_subdevice * s, int lsb, msb; int chan; - lsb = data[0] & 0xff; - msb = (data[0] >> 8) & 0xf; - chan = CR_CHAN(insn->chanspec); for (n = 0; n < insn->n; n++) { + lsb = data[n] & 0xff; + msb = (data[n] >> 8) & 0xf; #if 0 outb(lsb, dev->iobase + devpriv->ao_offset_lsb[chan]); outb(msb, dev->iobase + devpriv->ao_offset_msb[chan]); @@ -787,6 +785,9 @@ static int das08_counter_read(comedi_device * dev, comedi_subdevice * s, { int chan = insn->chanspec; + if (insn->n == 0) + return 0; + //printk("Reading counter channel %d ",chan); data[0] = i8254_read_channel(&devpriv->i8254, chan); //printk("=> 0x%08X\n",data[0]); @@ -799,6 +800,9 @@ static int das08_counter_write(comedi_device * dev, comedi_subdevice * s, { int chan = insn->chanspec; + if (insn->n == 0) + return 0; + //printk("Writing counter channel %d with 0x%04X\n",chan,data[0]); i8254_write_channel(&devpriv->i8254, chan, data[0]);