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 <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
H Hartley Sweeten 2013-06-12 16:19:50 -07:00 committed by Greg Kroah-Hartman
parent 8a1ec30d75
commit 46572bad94
2 changed files with 15 additions and 69 deletions

View 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,

View 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 {