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

staging: comedi: ii_pci20kc: use comedi_offset_munge()

For aesthetics, use the helper function to handle the munging of the
analog output data from offset binary to 2's complement and the analog
input data from 2's complement to offset binary.
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 c98f4011
...@@ -153,9 +153,8 @@ static int ii20k_ao_insn_write(struct comedi_device *dev, ...@@ -153,9 +153,8 @@ static int ii20k_ao_insn_write(struct comedi_device *dev,
s->readback[chan] = val; s->readback[chan] = val;
/* munge data */ /* munge the offset binary data to 2's complement */
val += ((s->maxdata + 1) >> 1); val = comedi_offset_munge(s, val);
val &= s->maxdata;
writeb(val & 0xff, iobase + II20K_AO_LSB_REG(chan)); writeb(val & 0xff, iobase + II20K_AO_LSB_REG(chan));
writeb((val >> 8) & 0xff, iobase + II20K_AO_MSB_REG(chan)); writeb((val >> 8) & 0xff, iobase + II20K_AO_MSB_REG(chan));
...@@ -243,11 +242,8 @@ static int ii20k_ai_insn_read(struct comedi_device *dev, ...@@ -243,11 +242,8 @@ static int ii20k_ai_insn_read(struct comedi_device *dev,
val = readb(iobase + II20K_AI_LSB_REG); val = readb(iobase + II20K_AI_LSB_REG);
val |= (readb(iobase + II20K_AI_MSB_REG) << 8); val |= (readb(iobase + II20K_AI_MSB_REG) << 8);
/* munge two's complement data */ /* munge the 2's complement data to offset binary */
val += ((s->maxdata + 1) >> 1); data[i] = comedi_offset_munge(s, val);
val &= s->maxdata;
data[i] = val;
} }
return insn->n; return insn->n;
......
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