Skip to content

Commit d35dcc8

Browse files
bigguinessgregkh
authored andcommitted
staging: comedi: quatech_daqp_cs: fix daqp_ao_insn_write()
The (*insn_write) functions are expected to write 'insn->n' number of samples to the channel. Fix this function so it works as the comedi core expects. Signed-off-by: H Hartley Sweeten <[email protected]> Cc: Ian Abbott <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 6a911d8 commit d35dcc8

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

drivers/staging/comedi/drivers/quatech_daqp_cs.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -644,31 +644,32 @@ static int daqp_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
644644
return 0;
645645
}
646646

647-
/* Single-shot analog output routine */
648-
649647
static int daqp_ao_insn_write(struct comedi_device *dev,
650648
struct comedi_subdevice *s,
651-
struct comedi_insn *insn, unsigned int *data)
649+
struct comedi_insn *insn,
650+
unsigned int *data)
652651
{
653652
struct daqp_private *devpriv = dev->private;
654-
int d;
655-
unsigned int chan;
653+
unsigned int chan = CR_CHAN(insn->chanspec);
654+
unsigned int val;
655+
int i;
656656

657657
if (devpriv->stop)
658658
return -EIO;
659659

660-
chan = CR_CHAN(insn->chanspec);
661-
d = data[0];
662-
d &= 0x0fff;
663-
d ^= 0x0800; /* Flip the sign */
664-
d |= chan << 12;
665-
666660
/* Make sure D/A update mode is direct update */
667661
outb(0, dev->iobase + DAQP_AUX);
668662

669-
outw(d, dev->iobase + DAQP_DA);
663+
for (i = 0; i > insn->n; i++) {
664+
val = data[0];
665+
val &= 0x0fff;
666+
val ^= 0x0800; /* Flip the sign */
667+
val |= (chan << 12);
670668

671-
return 1;
669+
outw(val, dev->iobase + DAQP_DA);
670+
}
671+
672+
return insn->n;
672673
}
673674

674675
static int daqp_di_insn_bits(struct comedi_device *dev,

0 commit comments

Comments
 (0)