staging: comedi: usbdux: tidy up usbdux_dio_insn_config()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Thu, 25 Jul 2013 23:05:53 +0000 (16:05 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 26 Jul 2013 22:09:55 +0000 (15:09 -0700)
Tidy up this function a bit.

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/usbdux.c

index 40e1424ce5a0ead0c8d631aaaad44b91d4d487b5..cdb02876a7190798e9dbcb3322fa5c432e093070 100644 (file)
@@ -1273,32 +1273,30 @@ ao_cmd_exit:
 
 static int usbdux_dio_insn_config(struct comedi_device *dev,
                                  struct comedi_subdevice *s,
-                                 struct comedi_insn *insn, unsigned int *data)
+                                 struct comedi_insn *insn,
+                                 unsigned int *data)
 {
-       int chan = CR_CHAN(insn->chanspec);
-
-       /* The input or output configuration of each digital line is
-        * configured by a special insn_config instruction.  chanspec
-        * contains the channel to be changed, and data[0] contains the
-        * value COMEDI_INPUT or COMEDI_OUTPUT. */
+       unsigned int mask = 1 << CR_CHAN(insn->chanspec);
 
        switch (data[0]) {
        case INSN_CONFIG_DIO_OUTPUT:
-               s->io_bits |= 1 << chan;        /* 1 means Out */
+               s->io_bits |= mask;
                break;
        case INSN_CONFIG_DIO_INPUT:
-               s->io_bits &= ~(1 << chan);
+               s->io_bits &= ~mask;
                break;
        case INSN_CONFIG_DIO_QUERY:
-               data[1] =
-                   (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
+               data[1] = (s->io_bits & mask) ? COMEDI_OUTPUT : COMEDI_INPUT;
                break;
        default:
                return -EINVAL;
                break;
        }
-       /* we don't tell the firmware here as it would take 8 frames */
-       /* to submit the information. We do it in the insn_bits. */
+
+       /*
+        * We don't tell the firmware here as it would take 8 frames
+        * to submit the information. We do it in the insn_bits.
+        */
        return insn->n;
 }