staging: comedi: addi_apci_3120: tidy up CTR0 register defines
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Tue, 4 Nov 2014 17:53:49 +0000 (10:53 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 7 Nov 2014 17:33:57 +0000 (09:33 -0800)
Define the CTR0 register in the main driver source file and remove all
the old defines in hwrdv_apci3120.c.

For aesthetics, save the raw digital output state (devpriv->do_bits) in
the digital output (*insn_bits) function and use a macro to set them when
reading/writing a timer.

Use the CTR0 register define in the digital output (*insn_bits) function
and remove the current register define.

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/addi-data/hwdrv_apci3120.c
drivers/staging/comedi/drivers/addi_apci_3120.c

index 7335a64d2d6ffb46b3a69932d69976995650cdd2..93b17252a9072560fdb62f33742f8f2ba144f1ee 100644 (file)
@@ -86,16 +86,9 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
 #define APCI3120_EOS_MODE              2
 #define APCI3120_DMA_MODE              3
 
-/* DIGITAL INPUT-OUTPUT DEFINE */
-
-#define APCI3120_DIGITAL_OUTPUT                0x0d
 #define APCI3120_RD_STATUS             0x02
 #define APCI3120_RD_FIFO               0x00
 
-/* digital output insn_write ON /OFF selection */
-#define        APCI3120_SET4DIGITALOUTPUTON    1
-#define APCI3120_SET4DIGITALOUTPUTOFF  0
-
 /* Enable external trigger bit in nWrAddress */
 #define APCI3120_ENABLE_EXT_TRIGGER    0x8000
 
@@ -110,7 +103,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
 #define APCI3120_RESET_FIFO            0x0c
 #define APCI3120_TIMER_0_MODE_2                0x01
 #define APCI3120_TIMER_0_MODE_4                0x2
-#define APCI3120_SELECT_TIMER_0_WORD   0x00
 #define APCI3120_ENABLE_TIMER0         0x1000
 #define APCI3120_CLEAR_PR              0xf0ff
 #define APCI3120_CLEAR_PA              0xfff0
@@ -148,8 +140,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
 #define APCI3120_ENABLE_TIMER_INT      0x04
 #define APCI3120_DISABLE_TIMER_INT     (~APCI3120_ENABLE_TIMER_INT)
 #define APCI3120_WRITE_MODE_SELECT     0x0e
-#define APCI3120_SELECT_TIMER_0_WORD   0x00
-#define APCI3120_SELECT_TIMER_1_WORD   0x01
 #define APCI3120_TIMER_1_MODE_2                0x4
 
 /* $$ BIT FOR MODE IN nCsTimerCtr1 */
@@ -157,11 +147,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
 #define APCI3120_TIMER_2_MODE_2                0x10
 #define APCI3120_TIMER_2_MODE_5                0x30
 
-/* $$ BIT FOR MODE IN nCsTimerCtr0 */
-#define APCI3120_SELECT_TIMER_2_LOW_WORD       0x02
-#define APCI3120_SELECT_TIMER_2_HIGH_WORD      0x03
-
-#define APCI3120_TIMER_CRT0            0x0d
 #define APCI3120_TIMER_CRT1            0x0c
 
 #define APCI3120_TIMER_VALUE           0x04
@@ -206,16 +191,16 @@ static void apci3120_timer_write(struct comedi_device *dev,
        struct apci3120_private *devpriv = dev->private;
 
        /* write 16-bit value to timer (lower 16-bits of timer 2) */
-       outb(((devpriv->do_bits) & 0xF0) |
+       outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) |
             APCI3120_CTR0_TIMER_SEL(timer),
-            dev->iobase + APCI3120_TIMER_CRT0);
+            dev->iobase + APCI3120_CTR0_REG);
        outw(val & 0xffff, dev->iobase + APCI3120_TIMER_VALUE);
 
        if (timer == 2) {
                /* write upper 16-bits to timer 2 */
-               outb(((devpriv->do_bits) & 0xF0) |
+               outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) |
                     APCI3120_CTR0_TIMER_SEL(timer + 1),
-                    dev->iobase + APCI3120_TIMER_CRT0);
+                    dev->iobase + APCI3120_CTR0_REG);
                outw((val >> 16) & 0xffff, dev->iobase + APCI3120_TIMER_VALUE);
        }
 }
@@ -227,16 +212,16 @@ static unsigned int apci3120_timer_read(struct comedi_device *dev,
        unsigned int val;
 
        /* read 16-bit value from timer (lower 16-bits of timer 2) */
-       outb(((devpriv->do_bits) & 0xF0) |
+       outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) |
             APCI3120_CTR0_TIMER_SEL(timer),
-            dev->iobase + APCI3120_TIMER_CRT0);
+            dev->iobase + APCI3120_CTR0_REG);
        val = inw(dev->iobase + APCI3120_TIMER_VALUE);
 
        if (timer == 2) {
                /* read upper 16-bits from timer 2 */
-               outb(((devpriv->do_bits) & 0xF0) |
+               outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) |
                     APCI3120_CTR0_TIMER_SEL(timer + 1),
-                    dev->iobase + APCI3120_TIMER_CRT0);
+                    dev->iobase + APCI3120_CTR0_REG);
                val |= (inw(dev->iobase + APCI3120_TIMER_VALUE) << 16);
        }
 
@@ -1693,10 +1678,9 @@ static int apci3120_do_insn_bits(struct comedi_device *dev,
        struct apci3120_private *devpriv = dev->private;
 
        if (comedi_dio_update_state(s, data)) {
-               /* The do channels are bits 7:4 of the do register */
-               devpriv->do_bits = s->state << 4;
-
-               outb(devpriv->do_bits, dev->iobase + APCI3120_DIGITAL_OUTPUT);
+               devpriv->do_bits = s->state;
+               outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits),
+                    dev->iobase + APCI3120_CTR0_REG);
        }
 
        data[1] = s->state;
index 6819cc09a60ef01c2e7cf2c4b7f720a7db2b8669..51637e1628bc34d081bd9fb50e1a851fccf81996 100644 (file)
@@ -19,6 +19,8 @@
 #define APCI3120_AO_REG(x)                     (0x08 + (((x) / 4) * 2))
 #define APCI3120_AO_MUX(x)                     (((x) & 0x3) << 14)
 #define APCI3120_AO_DATA(x)                    ((x) << 0)
+#define APCI3120_CTR0_REG                      0x0d
+#define APCI3120_CTR0_DO_BITS(x)               ((x) << 4)
 #define APCI3120_CTR0_TIMER_SEL(x)             ((x) << 0)
 
 /*
This page took 0.028163 seconds and 5 git commands to generate.