staging: comedi: skel: use comedi_dio_insn_config()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Tue, 6 Aug 2013 16:31:59 +0000 (09:31 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 12 Aug 2013 22:17:45 +0000 (15:17 -0700)
Convert this driver to use the comedi_dio_insn_config() helper function.

Tidy up the comments to reflect the new code.

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

index f76fd09e7bd311ae90e892b75c677e7d374c4cb3..9e964950a560ed92d9f37599d6138fd9c1a360b6 100644 (file)
@@ -362,31 +362,27 @@ static int skel_dio_insn_bits(struct comedi_device *dev,
 
 static int skel_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);
+       int ret;
 
-       /* 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;
-               break;
-       case INSN_CONFIG_DIO_INPUT:
-               s->io_bits &= ~(1 << chan);
-               break;
-       case INSN_CONFIG_DIO_QUERY:
-               data[1] =
-                   (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
-               return insn->n;
-               break;
-       default:
-               return -EINVAL;
-               break;
-       }
-       /* outw(s->io_bits,dev->iobase + SKEL_DIO_CONFIG); */
+       /*
+        * The input or output configuration of each digital line is
+        * configured by special insn_config instructions.
+        *
+        * chanspec contains the channel to be changed
+        * data[0] contains the instruction to perform on the channel
+        *
+        * Normally the core provided comedi_dio_insn_config() function
+        * can be used to handle the boilerplpate.
+        */
+       ret = comedi_dio_insn_config(dev, s, insn, data, 0);
+       if (ret)
+               return ret;
+
+       /* Update the hardware to the new configuration */
+       /* outw(s->io_bits, dev->iobase + SKEL_DIO_CONFIG); */
 
        return insn->n;
 }