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

staging: comedi: adl_pci6208: cleanup pci6208_ao_winsn()

Use the defines for the register map to make the code a bit
clearer. Shorten or rename some of the local variables for
the same reason.

Only the last value written to the DAC needs to be cached in
the ao_readback variable.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5c67df8b
...@@ -82,21 +82,24 @@ static int pci6208_ao_winsn(struct comedi_device *dev, ...@@ -82,21 +82,24 @@ static int pci6208_ao_winsn(struct comedi_device *dev,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
struct pci6208_private *devpriv = dev->private; struct pci6208_private *devpriv = dev->private;
int i = 0, Data_Read; int chan = CR_CHAN(insn->chanspec);
unsigned short chan = CR_CHAN(insn->chanspec);
unsigned long invert = 1 << (16 - 1); unsigned long invert = 1 << (16 - 1);
unsigned long out_value; unsigned long value = 0;
unsigned short status;
int i;
for (i = 0; i < insn->n; i++) { for (i = 0; i < insn->n; i++) {
out_value = data[i] ^ invert; value = data[i] ^ invert;
do { do {
Data_Read = (inw(dev->iobase) & 1); status = inw(dev->iobase + PCI6208_AO_STATUS);
} while (Data_Read); } while (status & PCI6208_AO_STATUS_DATA_SEND);
outw(out_value, dev->iobase + (0x02 * chan));
devpriv->ao_readback[chan] = out_value; outw(value, dev->iobase + PCI6208_AO_CONTROL(chan));
} }
devpriv->ao_readback[chan] = value;
return i; return insn->n;
} }
static int pci6208_ao_rinsn(struct comedi_device *dev, static int pci6208_ao_rinsn(struct comedi_device *dev,
......
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