From: H Hartley Sweeten Date: Wed, 12 Jun 2013 23:19:50 +0000 (-0700) Subject: staging: comedi: addi_apci_3xxx: tidy up i_APCI3XXX_InsnConfigAnalogInput() X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=46572bad94f97cbd16097a7b807f418c474d4ebe;p=linux-beck.git staging: comedi: addi_apci_3xxx: tidy up i_APCI3XXX_InsnConfigAnalogInput() 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 Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c index f9e8fdb7c8a1..b0092bea88fd 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c @@ -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, diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c index c0565942e983..c6cd30bdce96 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c @@ -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 {