]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
staging: comedi: rtd520: cleanup rtd_dio_insn_config()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Wed, 3 Apr 2013 18:37:46 +0000 (11:37 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Apr 2013 20:54:03 +0000 (13:54 -0700)
Add a local variable to make this function a bit cleaner and
remove the unnecessary comments.

The comedi core expects this function to return the number of
data parameters used. Change the return from '1' to 'insn->n'
to make this more apparent.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/rtd520.c

index 46ad048a1ab65c0c09087262929d1696b24c4df1..17c4da700744c3d4cced81ba4e371454723d16ac 100644 (file)
@@ -1244,30 +1244,24 @@ static int rtd_dio_insn_bits(struct comedi_device *dev,
        return insn->n;
 }
 
-/*
-  Configure one bit on a IO port as Input or Output (hence the name :-).
-*/
 static int rtd_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)
 {
        struct rtdPrivate *devpriv = dev->private;
-       int chan = CR_CHAN(insn->chanspec);
+       unsigned int chan = CR_CHAN(insn->chanspec);
+       unsigned int mask = 1 << chan;
 
-       /* 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. */
        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;
                return insn->n;
                break;
        default:
@@ -1287,7 +1281,7 @@ static int rtd_dio_insn_config(struct comedi_device *dev,
 
        /* there are also 2 user input lines and 2 user output lines */
 
-       return 1;
+       return insn->n;
 }
 
 static void rtd_reset(struct comedi_device *dev)