summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2015-10-08 20:30:44 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-10-13 08:58:35 +0300
commitd172b63a5570f8e0c8de859d04aada7514cdedea (patch)
tree3da3dd69bd8707a33b4785bbdd6fd3c8608b84a8
parentc98f4011ebd41ab9ff15e1c52acc446e1ee7e191 (diff)
downloadlinux-d172b63a5570f8e0c8de859d04aada7514cdedea.tar.xz
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: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/comedi/drivers/ii_pci20kc.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c
index 4d3f89c5e73e..1f3eaf6095da 100644
--- a/drivers/staging/comedi/drivers/ii_pci20kc.c
+++ b/drivers/staging/comedi/drivers/ii_pci20kc.c
@@ -153,9 +153,8 @@ static int ii20k_ao_insn_write(struct comedi_device *dev,
s->readback[chan] = val;
- /* munge data */
- val += ((s->maxdata + 1) >> 1);
- val &= s->maxdata;
+ /* munge the offset binary data to 2's complement */
+ val = comedi_offset_munge(s, val);
writeb(val & 0xff, iobase + II20K_AO_LSB_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,
val = readb(iobase + II20K_AI_LSB_REG);
val |= (readb(iobase + II20K_AI_MSB_REG) << 8);
- /* munge two's complement data */
- val += ((s->maxdata + 1) >> 1);
- val &= s->maxdata;
-
- data[i] = val;
+ /* munge the 2's complement data to offset binary */
+ data[i] = comedi_offset_munge(s, val);
}
return insn->n;