staging: comedi: addi_apci_3xxx: tidy up i_APCI3XXX_InsnConfigAnalogInput()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Wed, 12 Jun 2013 23:19:50 +0000 (16:19 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 17 Jun 2013 21:33:55 +0000 (14:33 -0700)
The analog input subdevice is broken in this driver. To help fix
it, tidy up this (*insn_config) function.

Rename the CamelCase function.

Move the (insn->n == 4) test from i_APCI3XXX_AnalogInputConfigOperatingMode()
to this function.

Make the function a bit more concise and remove the printk noise.

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_apci3xxx.c
drivers/staging/comedi/drivers/addi_apci_3xxx.c

index f9e8fdb..b0092be 100644 (file)
@@ -74,11 +74,6 @@ static int i_APCI3XXX_AnalogInputConfigOperatingMode(struct comedi_device *dev,
        unsigned int dw_ReloadValue = 0;
        unsigned int dw_TestReloadValue = 0;
 
-       /************************/
-       /* Test the buffer size */
-       /************************/
-
-       if (insn->n == 4) {
           /****************************/
                /* Get the Singel/Diff flag */
           /****************************/
@@ -213,75 +208,26 @@ static int i_APCI3XXX_AnalogInputConfigOperatingMode(struct comedi_device *dev,
                        printk("Convert time base unity selection error\n");
                        i_ReturnValue = -2;
                }
-       } else {
-          /*******************/
-               /* Data size error */
-          /*******************/
-
-               printk("Buffer size error\n");
-               i_ReturnValue = -101;
-       }
 
        return i_ReturnValue;
 }
 
-/*
-+----------------------------------------------------------------------------+
-| Function Name     : int   i_APCI3XXX_InsnConfigAnalogInput                 |
-|                          (struct comedi_device    *dev,                           |
-|                           struct comedi_subdevice *s,                             |
-|                           struct comedi_insn      *insn,                          |
-|                           unsigned int         *data)                          |
-+----------------------------------------------------------------------------+
-| Task           Converting mode and convert time selection                  |
-+----------------------------------------------------------------------------+
-| Input Parameters  : b_ConvertMode = (unsigned char)  data[0];                       |
-|                     b_TimeBase    = (unsigned char)  data[1]; (0: ns, 1:micros 2:ms)|
-|                    dw_ReloadValue = (unsigned int) data[2];                       |
-|                     ........                                               |
-+----------------------------------------------------------------------------+
-| Output Parameters : -                                                      |
-+----------------------------------------------------------------------------+
-| Return Value      :>0: No error                                            |
-|                    ....                                                    |
-|                    -100 : Config command error                             |
-|                    -101 : Data size error                                  |
-+----------------------------------------------------------------------------+
-*/
-static int i_APCI3XXX_InsnConfigAnalogInput(struct comedi_device *dev,
-                                           struct comedi_subdevice *s,
-                                           struct comedi_insn *insn,
-                                           unsigned int *data)
+static int apci3xxx_ai_insn_config(struct comedi_device *dev,
+                                  struct comedi_subdevice *s,
+                                  struct comedi_insn *insn,
+                                  unsigned int *data)
 {
-       int i_ReturnValue = insn->n;
-
-       /************************/
-       /* Test the buffer size */
-       /************************/
-
-       if (insn->n >= 1) {
-               switch ((unsigned char) data[0]) {
-               case APCI3XXX_CONFIGURATION:
-                       i_ReturnValue =
-                               i_APCI3XXX_AnalogInputConfigOperatingMode(dev,
-                               s, insn, data);
-                       break;
-
-               default:
-                       i_ReturnValue = -100;
-                       printk("Config command error %d\n", data[0]);
-                       break;
-               }
-       } else {
-          /*******************/
-               /* Data size error */
-          /*******************/
-
-               printk("Buffer size error\n");
-               i_ReturnValue = -101;
+       switch (data[0]) {
+       case APCI3XXX_CONFIGURATION:
+               if (insn->n == 4)
+                       return i_APCI3XXX_AnalogInputConfigOperatingMode(dev,
+                                       s, insn, data);
+               else
+                       return -EINVAL;
+               break;
+       default:
+               return -EINVAL;
        }
-
-       return i_ReturnValue;
 }
 
 static int apci3xxx_ai_insn_read(struct comedi_device *dev,
index c056594..c6cd30b 100644 (file)
@@ -631,7 +631,7 @@ static int apci3xxx_auto_attach(struct comedi_device *dev,
                s->len_chanlist = s->n_chan;
                s->range_table = &apci3xxx_ai_range;
 
-               s->insn_config = i_APCI3XXX_InsnConfigAnalogInput;
+               s->insn_config = apci3xxx_ai_insn_config;
                s->insn_read = apci3xxx_ai_insn_read;
 
        } else {