[PATCH 09/17] staging: comedi: quatech_daqp_cs: use comedi_offset_munge() in ao (*insn_write)

H Hartley Sweeten hsweeten at visionengravers.com
Thu Oct 1 17:58:58 UTC 2015


Use the comedi_offset_munge() helper to do the offset binary to two's
complement conversion when writing a new analog output value.

Signed-off-by: H Hartley Sweeten <hsweeten at visionengravers.com>
Cc: Ian Abbott <abbotti at mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
---
 drivers/staging/comedi/drivers/quatech_daqp_cs.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
index 23c79e3..9514544 100644
--- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c
+++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
@@ -594,11 +594,9 @@ static int daqp_ao_insn_write(struct comedi_device *dev,
 
 		s->readback[chan] = val;
 
-		val &= 0x0fff;
-		val ^= 0x0800;		/* Flip the sign */
-		val |= (chan << 12);
-
-		outw(val, dev->iobase + DAQP_DA);
+		/* write the two's complement value to the channel */
+		outw((chan << 12) | comedi_offset_munge(s, val),
+		     dev->iobase + DAQP_DA);
 	}
 
 	return insn->n;
-- 
2.5.1



More information about the devel mailing list