From 37f9ebfcc63ad83a610fdcbb9140dbff3b84a4d3 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 15 Dec 2011 21:10:21 +0000 Subject: [PATCH] me_daq: 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 for INSN_WRITE on the AO subdevice, write the nth data value in the loop instead of the 0th data value. Signed-off-by: Ian Abbott --- comedi/drivers/me_daq.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/comedi/drivers/me_daq.c b/comedi/drivers/me_daq.c index a2ef34b9..e13ebf0a 100644 --- a/comedi/drivers/me_daq.c +++ b/comedi/drivers/me_daq.c @@ -379,6 +379,9 @@ static int me_ai_insn_read(comedi_device * dev, int aref = CR_AREF((&insn->chanspec)[0]); int i; + if (insn->n == 0) + return 0; + /* stop any running conversion */ dev_private->control_1 &= 0xFFFC; writew(dev_private->control_1, dev_private->me_regbase + ME_CONTROL_1); @@ -515,9 +518,9 @@ static int me_ao_insn_write(comedi_device * dev, /* Set data register */ for (i = 0; i < insn->n; i++) { chan = CR_CHAN((&insn->chanspec)[i]); - writew((data[0] & s->maxdata), + writew((data[i] & s->maxdata), dev_private->me_regbase + ME_DAC_DATA_A + (chan << 1)); - dev_private->ao_readback[chan] = (data[0] & s->maxdata); + dev_private->ao_readback[chan] = (data[i] & s->maxdata); } /* Update dac with data registers */ -- 2.26.2