[PATCH 4/9] staging: comedi: adl_pci6208: use comedi_offset_munge()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 drivers/staging/comedi/drivers/adl_pci6208.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/comedi/drivers/adl_pci6208.c b/drivers/staging/comedi/drivers/adl_pci6208.c
index 059d7ea..db808733 100644
--- a/drivers/staging/comedi/drivers/adl_pci6208.c
+++ b/drivers/staging/comedi/drivers/adl_pci6208.c
@@ -104,7 +104,6 @@ static int pci6208_ao_winsn(struct comedi_device *dev,
 {
 	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;
@@ -117,7 +116,9 @@ static int pci6208_ao_winsn(struct comedi_device *dev,
 		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;
 
-- 
1.8.3.2

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux