staging: comedi: addi_apci_3xxx: fix digital input 'insn_bits' function
This driver does not follow the comedi API. The digital input 'insn_bits' function is supposed to return the status of all the input channels in data[1]. Currently this function is returning the status in data[0]. It is also unnecessarily testing the size of the return buffer. Fix the function so it works like the comedi core expects. The core can then use the function to emulate the 'insn_read' function for individual channels. This allows removing the i_APCI3XXX_InsnReadDigitalInput() function. 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>
This commit is contained in:
parent
141dcc33c0
commit
10f71c7845
2 changed files with 20 additions and 137 deletions
|
@ -1276,119 +1276,16 @@ static int i_APCI3XXX_InsnWriteTTLIO(struct comedi_device *dev,
|
|||
return i_ReturnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
+----------------------------------------------------------------------------+
|
||||
| DIGITAL INPUT SUBDEVICE |
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/*
|
||||
+----------------------------------------------------------------------------+
|
||||
| Function name :int i_APCI3XXX_InsnReadDigitalInput |
|
||||
| (struct comedi_device *dev, |
|
||||
| struct comedi_subdevice *s, |
|
||||
| struct comedi_insn *insn, |
|
||||
| unsigned int *data) |
|
||||
+----------------------------------------------------------------------------+
|
||||
| Task : Reads the value of the specified Digital input channel |
|
||||
+----------------------------------------------------------------------------+
|
||||
| Input Parameters : b_Channel = CR_CHAN(insn->chanspec) (0 to 3) |
|
||||
+----------------------------------------------------------------------------+
|
||||
| Output Parameters : data[0] : Channel value |
|
||||
+----------------------------------------------------------------------------+
|
||||
| Return Value : 0 : No error |
|
||||
| -3 : Channel selection error |
|
||||
| -101 : Data size error |
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
static int i_APCI3XXX_InsnReadDigitalInput(struct comedi_device *dev,
|
||||
struct comedi_subdevice *s,
|
||||
struct comedi_insn *insn,
|
||||
unsigned int *data)
|
||||
static int apci3xxx_di_insn_bits(struct comedi_device *dev,
|
||||
struct comedi_subdevice *s,
|
||||
struct comedi_insn *insn,
|
||||
unsigned int *data)
|
||||
{
|
||||
struct addi_private *devpriv = dev->private;
|
||||
int i_ReturnValue = insn->n;
|
||||
unsigned char b_Channel = (unsigned char) CR_CHAN(insn->chanspec);
|
||||
unsigned int dw_Temp = 0;
|
||||
|
||||
/***************************/
|
||||
/* Test the channel number */
|
||||
/***************************/
|
||||
data[1] = inl(devpriv->iobase + 32) & 0xf;
|
||||
|
||||
if (b_Channel <= devpriv->s_EeParameters.i_NbrDiChannel) {
|
||||
/************************/
|
||||
/* Test the buffer size */
|
||||
/************************/
|
||||
|
||||
if (insn->n >= 1) {
|
||||
dw_Temp = inl(devpriv->iobase + 32);
|
||||
*data = (dw_Temp >> b_Channel) & 1;
|
||||
} else {
|
||||
/*******************/
|
||||
/* Data size error */
|
||||
/*******************/
|
||||
|
||||
printk("Buffer size error\n");
|
||||
i_ReturnValue = -101;
|
||||
}
|
||||
} else {
|
||||
/***************************/
|
||||
/* Channel selection error */
|
||||
/***************************/
|
||||
|
||||
printk("Channel selection error\n");
|
||||
i_ReturnValue = -3;
|
||||
}
|
||||
|
||||
return i_ReturnValue;
|
||||
}
|
||||
|
||||
/*
|
||||
+----------------------------------------------------------------------------+
|
||||
| Function name :int i_APCI3XXX_InsnBitsDigitalInput |
|
||||
| (struct comedi_device *dev, |
|
||||
| struct comedi_subdevice *s, |
|
||||
| struct comedi_insn *insn, |
|
||||
| unsigned int *data) |
|
||||
+----------------------------------------------------------------------------+
|
||||
| Task : Reads the value of the Digital input Port i.e.4channels|
|
||||
+----------------------------------------------------------------------------+
|
||||
| Input Parameters : - |
|
||||
+----------------------------------------------------------------------------+
|
||||
| Output Parameters : data[0] : Port value |
|
||||
+----------------------------------------------------------------------------+
|
||||
| Return Value :>0: No error |
|
||||
| .... |
|
||||
| -101 : Data size error |
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
static int i_APCI3XXX_InsnBitsDigitalInput(struct comedi_device *dev,
|
||||
struct comedi_subdevice *s,
|
||||
struct comedi_insn *insn,
|
||||
unsigned int *data)
|
||||
{
|
||||
struct addi_private *devpriv = dev->private;
|
||||
int i_ReturnValue = insn->n;
|
||||
unsigned int dw_Temp = 0;
|
||||
|
||||
/************************/
|
||||
/* Test the buffer size */
|
||||
/************************/
|
||||
|
||||
if (insn->n >= 1) {
|
||||
dw_Temp = inl(devpriv->iobase + 32);
|
||||
*data = dw_Temp & 0xf;
|
||||
} else {
|
||||
/*******************/
|
||||
/* Data size error */
|
||||
/*******************/
|
||||
|
||||
printk("Buffer size error\n");
|
||||
i_ReturnValue = -101;
|
||||
}
|
||||
|
||||
return i_ReturnValue;
|
||||
return insn->n;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -190,8 +190,7 @@ static const struct addi_board apci3xxx_boardtypes[] = {
|
|||
.reset = i_APCI3XXX_Reset,
|
||||
.ai_config = i_APCI3XXX_InsnConfigAnalogInput,
|
||||
.ai_read = i_APCI3XXX_InsnReadAnalogInput,
|
||||
.di_read = i_APCI3XXX_InsnReadDigitalInput,
|
||||
.di_bits = i_APCI3XXX_InsnBitsDigitalInput,
|
||||
.di_bits = apci3xxx_di_insn_bits,
|
||||
.do_write = i_APCI3XXX_InsnWriteDigitalOutput,
|
||||
.do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
|
||||
.do_read = i_APCI3XXX_InsnReadDigitalOutput,
|
||||
|
@ -224,8 +223,7 @@ static const struct addi_board apci3xxx_boardtypes[] = {
|
|||
.reset = i_APCI3XXX_Reset,
|
||||
.ai_config = i_APCI3XXX_InsnConfigAnalogInput,
|
||||
.ai_read = i_APCI3XXX_InsnReadAnalogInput,
|
||||
.di_read = i_APCI3XXX_InsnReadDigitalInput,
|
||||
.di_bits = i_APCI3XXX_InsnBitsDigitalInput,
|
||||
.di_bits = apci3xxx_di_insn_bits,
|
||||
.do_write = i_APCI3XXX_InsnWriteDigitalOutput,
|
||||
.do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
|
||||
.do_read = i_APCI3XXX_InsnReadDigitalOutput,
|
||||
|
@ -258,8 +256,7 @@ static const struct addi_board apci3xxx_boardtypes[] = {
|
|||
.reset = i_APCI3XXX_Reset,
|
||||
.ai_config = i_APCI3XXX_InsnConfigAnalogInput,
|
||||
.ai_read = i_APCI3XXX_InsnReadAnalogInput,
|
||||
.di_read = i_APCI3XXX_InsnReadDigitalInput,
|
||||
.di_bits = i_APCI3XXX_InsnBitsDigitalInput,
|
||||
.di_bits = apci3xxx_di_insn_bits,
|
||||
.do_write = i_APCI3XXX_InsnWriteDigitalOutput,
|
||||
.do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
|
||||
.do_read = i_APCI3XXX_InsnReadDigitalOutput,
|
||||
|
@ -292,8 +289,7 @@ static const struct addi_board apci3xxx_boardtypes[] = {
|
|||
.reset = i_APCI3XXX_Reset,
|
||||
.ai_config = i_APCI3XXX_InsnConfigAnalogInput,
|
||||
.ai_read = i_APCI3XXX_InsnReadAnalogInput,
|
||||
.di_read = i_APCI3XXX_InsnReadDigitalInput,
|
||||
.di_bits = i_APCI3XXX_InsnBitsDigitalInput,
|
||||
.di_bits = apci3xxx_di_insn_bits,
|
||||
.do_write = i_APCI3XXX_InsnWriteDigitalOutput,
|
||||
.do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
|
||||
.do_read = i_APCI3XXX_InsnReadDigitalOutput,
|
||||
|
@ -326,8 +322,7 @@ static const struct addi_board apci3xxx_boardtypes[] = {
|
|||
.reset = i_APCI3XXX_Reset,
|
||||
.ai_config = i_APCI3XXX_InsnConfigAnalogInput,
|
||||
.ai_read = i_APCI3XXX_InsnReadAnalogInput,
|
||||
.di_read = i_APCI3XXX_InsnReadDigitalInput,
|
||||
.di_bits = i_APCI3XXX_InsnBitsDigitalInput,
|
||||
.di_bits = apci3xxx_di_insn_bits,
|
||||
.do_write = i_APCI3XXX_InsnWriteDigitalOutput,
|
||||
.do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
|
||||
.do_read = i_APCI3XXX_InsnReadDigitalOutput,
|
||||
|
@ -360,8 +355,7 @@ static const struct addi_board apci3xxx_boardtypes[] = {
|
|||
.reset = i_APCI3XXX_Reset,
|
||||
.ai_config = i_APCI3XXX_InsnConfigAnalogInput,
|
||||
.ai_read = i_APCI3XXX_InsnReadAnalogInput,
|
||||
.di_read = i_APCI3XXX_InsnReadDigitalInput,
|
||||
.di_bits = i_APCI3XXX_InsnBitsDigitalInput,
|
||||
.di_bits = apci3xxx_di_insn_bits,
|
||||
.do_write = i_APCI3XXX_InsnWriteDigitalOutput,
|
||||
.do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
|
||||
.do_read = i_APCI3XXX_InsnReadDigitalOutput,
|
||||
|
@ -518,8 +512,7 @@ static const struct addi_board apci3xxx_boardtypes[] = {
|
|||
.ai_config = i_APCI3XXX_InsnConfigAnalogInput,
|
||||
.ai_read = i_APCI3XXX_InsnReadAnalogInput,
|
||||
.ao_write = i_APCI3XXX_InsnWriteAnalogOutput,
|
||||
.di_read = i_APCI3XXX_InsnReadDigitalInput,
|
||||
.di_bits = i_APCI3XXX_InsnBitsDigitalInput,
|
||||
.di_bits = apci3xxx_di_insn_bits,
|
||||
.do_write = i_APCI3XXX_InsnWriteDigitalOutput,
|
||||
.do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
|
||||
.do_read = i_APCI3XXX_InsnReadDigitalOutput,
|
||||
|
@ -556,8 +549,7 @@ static const struct addi_board apci3xxx_boardtypes[] = {
|
|||
.ai_config = i_APCI3XXX_InsnConfigAnalogInput,
|
||||
.ai_read = i_APCI3XXX_InsnReadAnalogInput,
|
||||
.ao_write = i_APCI3XXX_InsnWriteAnalogOutput,
|
||||
.di_read = i_APCI3XXX_InsnReadDigitalInput,
|
||||
.di_bits = i_APCI3XXX_InsnBitsDigitalInput,
|
||||
.di_bits = apci3xxx_di_insn_bits,
|
||||
.do_write = i_APCI3XXX_InsnWriteDigitalOutput,
|
||||
.do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
|
||||
.do_read = i_APCI3XXX_InsnReadDigitalOutput,
|
||||
|
@ -594,8 +586,7 @@ static const struct addi_board apci3xxx_boardtypes[] = {
|
|||
.ai_config = i_APCI3XXX_InsnConfigAnalogInput,
|
||||
.ai_read = i_APCI3XXX_InsnReadAnalogInput,
|
||||
.ao_write = i_APCI3XXX_InsnWriteAnalogOutput,
|
||||
.di_read = i_APCI3XXX_InsnReadDigitalInput,
|
||||
.di_bits = i_APCI3XXX_InsnBitsDigitalInput,
|
||||
.di_bits = apci3xxx_di_insn_bits,
|
||||
.do_write = i_APCI3XXX_InsnWriteDigitalOutput,
|
||||
.do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
|
||||
.do_read = i_APCI3XXX_InsnReadDigitalOutput,
|
||||
|
@ -632,8 +623,7 @@ static const struct addi_board apci3xxx_boardtypes[] = {
|
|||
.ai_config = i_APCI3XXX_InsnConfigAnalogInput,
|
||||
.ai_read = i_APCI3XXX_InsnReadAnalogInput,
|
||||
.ao_write = i_APCI3XXX_InsnWriteAnalogOutput,
|
||||
.di_read = i_APCI3XXX_InsnReadDigitalInput,
|
||||
.di_bits = i_APCI3XXX_InsnBitsDigitalInput,
|
||||
.di_bits = apci3xxx_di_insn_bits,
|
||||
.do_write = i_APCI3XXX_InsnWriteDigitalOutput,
|
||||
.do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
|
||||
.do_read = i_APCI3XXX_InsnReadDigitalOutput,
|
||||
|
@ -664,8 +654,7 @@ static const struct addi_board apci3xxx_boardtypes[] = {
|
|||
.reset = i_APCI3XXX_Reset,
|
||||
.ai_config = i_APCI3XXX_InsnConfigAnalogInput,
|
||||
.ai_read = i_APCI3XXX_InsnReadAnalogInput,
|
||||
.di_read = i_APCI3XXX_InsnReadDigitalInput,
|
||||
.di_bits = i_APCI3XXX_InsnBitsDigitalInput,
|
||||
.di_bits = apci3xxx_di_insn_bits,
|
||||
.do_write = i_APCI3XXX_InsnWriteDigitalOutput,
|
||||
.do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
|
||||
.do_read = i_APCI3XXX_InsnReadDigitalOutput,
|
||||
|
@ -692,8 +681,7 @@ static const struct addi_board apci3xxx_boardtypes[] = {
|
|||
.reset = i_APCI3XXX_Reset,
|
||||
.ai_config = i_APCI3XXX_InsnConfigAnalogInput,
|
||||
.ai_read = i_APCI3XXX_InsnReadAnalogInput,
|
||||
.di_read = i_APCI3XXX_InsnReadDigitalInput,
|
||||
.di_bits = i_APCI3XXX_InsnBitsDigitalInput,
|
||||
.di_bits = apci3xxx_di_insn_bits,
|
||||
.do_write = i_APCI3XXX_InsnWriteDigitalOutput,
|
||||
.do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
|
||||
.do_read = i_APCI3XXX_InsnReadDigitalOutput,
|
||||
|
@ -720,8 +708,7 @@ static const struct addi_board apci3xxx_boardtypes[] = {
|
|||
.reset = i_APCI3XXX_Reset,
|
||||
.ai_config = i_APCI3XXX_InsnConfigAnalogInput,
|
||||
.ai_read = i_APCI3XXX_InsnReadAnalogInput,
|
||||
.di_read = i_APCI3XXX_InsnReadDigitalInput,
|
||||
.di_bits = i_APCI3XXX_InsnBitsDigitalInput,
|
||||
.di_bits = apci3xxx_di_insn_bits,
|
||||
.do_write = i_APCI3XXX_InsnWriteDigitalOutput,
|
||||
.do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
|
||||
.do_read = i_APCI3XXX_InsnReadDigitalOutput,
|
||||
|
@ -748,8 +735,7 @@ static const struct addi_board apci3xxx_boardtypes[] = {
|
|||
.reset = i_APCI3XXX_Reset,
|
||||
.ai_config = i_APCI3XXX_InsnConfigAnalogInput,
|
||||
.ai_read = i_APCI3XXX_InsnReadAnalogInput,
|
||||
.di_read = i_APCI3XXX_InsnReadDigitalInput,
|
||||
.di_bits = i_APCI3XXX_InsnBitsDigitalInput,
|
||||
.di_bits = apci3xxx_di_insn_bits,
|
||||
.do_write = i_APCI3XXX_InsnWriteDigitalOutput,
|
||||
.do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
|
||||
.do_read = i_APCI3XXX_InsnReadDigitalOutput,
|
||||
|
|
Loading…
Reference in a new issue