staging: comedi: hwdrv_apci3120: use comedi_dio_update_state()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Fri, 30 Aug 2013 18:09:07 +0000 (11:09 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 17 Sep 2013 14:47:41 +0000 (07:47 -0700)
Use comedi_dio_update_state() to handle the boilerplate code to update
the subdevice s->state.

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

index 1449b92403e249ff2e1198dfdcc2dece751105ee..ac6e75d62e6129bf1cca8e817a64ac032c8080fb 100644 (file)
@@ -2175,21 +2175,16 @@ static int apci3120_do_insn_bits(struct comedi_device *dev,
                                 unsigned int *data)
 {
        struct addi_private *devpriv = dev->private;
-       unsigned int mask = data[0];
-       unsigned int bits = data[1];
-       unsigned int val;
 
-       /* The do channels are bits 7:4 of the do register */
-       val = devpriv->b_DigitalOutputRegister >> 4;
-       if (mask) {
-               val &= ~mask;
-               val |= (bits & mask);
-               devpriv->b_DigitalOutputRegister = val << 4;
+       if (comedi_dio_update_state(s, data)) {
+               /* The do channels are bits 7:4 of the do register */
+               devpriv->b_DigitalOutputRegister = s->state << 4;
 
-               outb(val << 4, devpriv->iobase + APCI3120_DIGITAL_OUTPUT);
+               outb(devpriv->b_DigitalOutputRegister,
+                    devpriv->iobase + APCI3120_DIGITAL_OUTPUT);
        }
 
-       data[1] = val;
+       data[1] = s->state;
 
        return insn->n;
 }