staging: comedi: cb_pcidas: cleanup ai_config_insn()
authorH Hartley Sweeten <hartleys@visionengravers.com>
Wed, 27 Jun 2012 01:01:05 +0000 (18:01 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Jul 2012 22:23:52 +0000 (15:23 -0700)
Absorb the helper function ai_config_calibration_source() into
ai_config_insn() and remove the static const variable that
was in the helper function.

Return an error code (-EINVAL) when appropriate and the number
of data values used (insn->n) for success.

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

index 3cdd026767c14bed6d7514a34e91d6eb67bca04e..a2901bb50e010b3d14d96c5ab67f84a23b8c6c24 100644 (file)
@@ -439,38 +439,28 @@ static int cb_pcidas_ai_rinsn(struct comedi_device *dev,
        return n;
 }
 
-static int ai_config_calibration_source(struct comedi_device *dev,
-                                       unsigned int *data)
-{
-       struct cb_pcidas_private *devpriv = dev->private;
-       static const int num_calibration_sources = 8;
-       unsigned int source = data[1];
-
-       if (source >= num_calibration_sources) {
-               dev_err(dev->class_dev, "invalid calibration source: %i\n",
-                       source);
-               return -EINVAL;
-       }
-
-       devpriv->calibration_source = source;
-
-       return 2;
-}
-
 static int ai_config_insn(struct comedi_device *dev, struct comedi_subdevice *s,
                          struct comedi_insn *insn, unsigned int *data)
 {
+       struct cb_pcidas_private *devpriv = dev->private;
        int id = data[0];
+       unsigned int source = data[1];
 
        switch (id) {
        case INSN_CONFIG_ALT_SOURCE:
-               return ai_config_calibration_source(dev, data);
+               if (source >= 8) {
+                       dev_err(dev->class_dev,
+                               "invalid calibration source: %i\n",
+                               source);
+                       return -EINVAL;
+               }
+               devpriv->calibration_source = source;
                break;
        default:
                return -EINVAL;
                break;
        }
-       return -EINVAL;
+       return insn->n;
 }
 
 /* analog output insn for pcidas-1000 and 1200 series */