Use comedi_offset_munge() to munge the offset binary values from the
comedi core into the two's complement form that the hardware expects.
This removes the hard coded assumption that the analog outputs are
16-bits and instead does the munging based on the s->maxdata.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
{
struct pci6208_private *devpriv = dev->private;
int chan = CR_CHAN(insn->chanspec);
- unsigned int invert = 1 << (16 - 1);
unsigned int val = devpriv->ao_readback[chan];
int ret;
int i;
if (ret)
return ret;
- outw(val ^ invert, dev->iobase + PCI6208_AO_CONTROL(chan));
+ /* the hardware expects two's complement values */
+ outw(comedi_offset_munge(s, val),
+ dev->iobase + PCI6208_AO_CONTROL(chan));
}
devpriv->ao_readback[chan] = val;