[PATCH 1/9] staging: comedi: adl_pci6208: save raw data for analog output readback

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

 



This driver munges the raw data from the comedi core into its two's
complement form before writing it to the hardware. The last value
written to the hardware is saved in the private data for readback.

Since the comedi core always expects the data to be in offset binary
coding, make sure to save the un-munged value for readback.

Also, prefetch the current readback value before attempting to update
the hardware. This ensures that the readback value is correct if no
values are actually written.

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 | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/comedi/drivers/adl_pci6208.c b/drivers/staging/comedi/drivers/adl_pci6208.c
index 60f1f5c..9150582 100644
--- a/drivers/staging/comedi/drivers/adl_pci6208.c
+++ b/drivers/staging/comedi/drivers/adl_pci6208.c
@@ -88,21 +88,21 @@ static int pci6208_ao_winsn(struct comedi_device *dev,
 {
 	struct pci6208_private *devpriv = dev->private;
 	int chan = CR_CHAN(insn->chanspec);
-	unsigned long invert = 1 << (16 - 1);
-	unsigned long value = 0;
+	unsigned int invert = 1 << (16 - 1);
+	unsigned int val = devpriv->ao_readback[chan];
 	unsigned short status;
 	int i;
 
 	for (i = 0; i < insn->n; i++) {
-		value = data[i] ^ invert;
+		val = data[i];
 
 		do {
 			status = inw(dev->iobase + PCI6208_AO_STATUS);
 		} while (status & PCI6208_AO_STATUS_DATA_SEND);
 
-		outw(value, dev->iobase + PCI6208_AO_CONTROL(chan));
+		outw(val ^ invert, dev->iobase + PCI6208_AO_CONTROL(chan));
 	}
-	devpriv->ao_readback[chan] = value;
+	devpriv->ao_readback[chan] = val;
 
 	return insn->n;
 }
-- 
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