staging: comedi: adl_pci9118: tidy up analog output register defines
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Thu, 4 Sep 2014 19:14:13 +0000 (12:14 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 8 Sep 2014 20:55:53 +0000 (13:55 -0700)
Replace the current defines with a macro that calculates the correct
register offset based on the channel.

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>
drivers/staging/comedi/drivers/adl_pci9118.c

index 7c2385b8ad34851f2463198d13b850b2dcc9696e..5c9bb73e06f1db2f3f58f43830c861b523ecc41b 100644 (file)
 #define PCI9118_TIMER_REG(x)           (0x00 + ((x) * 4))
 #define PCI9118_TIMER_CTRL_REG         0x0c
 #define PCI9118_AI_FIFO_REG            0x10
+#define PCI9118_AO_REG(x)              (0x10 + ((x) * 4))
 
-#define PCI9118_DA1    0x10    /* W:   D/A registers */
-#define PCI9118_DA2    0x14
 #define PCI9118_ADSTAT 0x18    /* R:   A/D status register */
 #define PCI9118_ADCNTRL        0x18    /* W:   A/D control register */
 #define PCI9118_DI     0x1c    /* R:   digi input register */
@@ -559,18 +558,12 @@ static int pci9118_insn_write_ao(struct comedi_device *dev,
                                 struct comedi_insn *insn, unsigned int *data)
 {
        struct pci9118_private *devpriv = dev->private;
-       int n, chanreg, ch;
-
-       ch = CR_CHAN(insn->chanspec);
-       if (ch)
-               chanreg = PCI9118_DA2;
-       else
-               chanreg = PCI9118_DA1;
-
+       unsigned int chan = CR_CHAN(insn->chanspec);
+       int n;
 
        for (n = 0; n < insn->n; n++) {
-               outl(data[n], dev->iobase + chanreg);
-               devpriv->ao_data[ch] = data[n];
+               outl(data[n], dev->iobase + PCI9118_AO_REG(chan));
+               devpriv->ao_data[chan] = data[n];
        }
 
        return n;
@@ -1717,11 +1710,12 @@ static int pci9118_reset(struct comedi_device *dev)
                                                 * trigger stop
                                                 */
 
+       /* reset analog outputs to 0V */
        devpriv->ao_data[0] = 2047;
        devpriv->ao_data[1] = 2047;
-       outl(devpriv->ao_data[0], dev->iobase + PCI9118_DA1);
-                                               /* reset A/D outs to 0V */
-       outl(devpriv->ao_data[1], dev->iobase + PCI9118_DA2);
+       outl(devpriv->ao_data[0], dev->iobase + PCI9118_AO_REG(0));
+       outl(devpriv->ao_data[1], dev->iobase + PCI9118_AO_REG(1));
+
        outl(0, dev->iobase + PCI9118_DO);      /* reset digi outs to L */
        udelay(10);
        inl(dev->iobase + PCI9118_AI_FIFO_REG);