Commit 4c6f738e authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: das1800: tidy up das1800_ao_insn_write()

The (*insn_write) functions are supposed to write insn->n values to the
specified channel. Tidy up this function and make it work like the core
expects.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 605b670e
...@@ -1086,30 +1086,36 @@ static int das1800_ao_insn_write(struct comedi_device *dev, ...@@ -1086,30 +1086,36 @@ static int das1800_ao_insn_write(struct comedi_device *dev,
struct comedi_insn *insn, struct comedi_insn *insn,
unsigned int *data) unsigned int *data)
{ {
const struct das1800_board *board = dev->board_ptr;
struct das1800_private *devpriv = dev->private; struct das1800_private *devpriv = dev->private;
int chan = CR_CHAN(insn->chanspec); unsigned int chan = CR_CHAN(insn->chanspec);
/* int range = CR_RANGE(insn->chanspec); */ unsigned int update_chan = s->n_chan - 1;
int update_chan = board->ao_n_chan - 1; unsigned long flags;
unsigned short output; int i;
unsigned long irq_flags;
output = comedi_offset_munge(s, data[0]); /* protects the indirect addressing selected by DAS1800_SELECT */
/* if the write is to the 'update' channel, we need to remember its value */ spin_lock_irqsave(&dev->spinlock, flags);
if (chan == update_chan)
devpriv->ao_update_bits = output; for (i = 0; i < insn->n; i++) {
/* write to channel */ unsigned int val = data[i];
spin_lock_irqsave(&dev->spinlock, irq_flags);
outb(DAC(chan), dev->iobase + DAS1800_SELECT); /* select dac channel for baseAddress + 0x0 */ val = comedi_offset_munge(s, val);
outw(output, dev->iobase + DAS1800_DAC); if (chan == update_chan)
/* now we need to write to 'update' channel to update all dac channels */ devpriv->ao_update_bits = val;
if (chan != update_chan) {
outb(DAC(update_chan), dev->iobase + DAS1800_SELECT); /* select 'update' channel for baseAddress + 0x0 */ /* load this channel (and update if it's the last channel) */
outw(devpriv->ao_update_bits, dev->iobase + DAS1800_DAC); outb(DAC(chan), dev->iobase + DAS1800_SELECT);
outw(val, dev->iobase + DAS1800_DAC);
/* update all channels */
if (chan != update_chan) {
outb(DAC(update_chan), dev->iobase + DAS1800_SELECT);
outw(devpriv->ao_update_bits,
dev->iobase + DAS1800_DAC);
}
} }
spin_unlock_irqrestore(&dev->spinlock, irq_flags); spin_unlock_irqrestore(&dev->spinlock, flags);
return 1; return insn->n;
} }
static int das1800_di_insn_bits(struct comedi_device *dev, static int das1800_di_insn_bits(struct comedi_device *dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment