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@xxxxxxxxxxxxxxxxxxx> Cc: Ian Abbott <abbotti@xxxxxxxxx> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- .../comedi/drivers/addi-data/hwdrv_apci3xxx.c | 115 ++------------------- drivers/staging/comedi/drivers/addi_apci_3xxx.c | 42 +++----- 2 files changed, 20 insertions(+), 137 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c index d1b0ee6..5d3570c 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c @@ -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) -{ - 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 */ - /***************************/ - - 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) +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 int dw_Temp = 0; - /************************/ - /* Test the buffer size */ - /************************/ + data[1] = inl(devpriv->iobase + 32) & 0xf; - 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; } /* diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c index 00c972e..d0cd2e8 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c @@ -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, -- 1.7.11 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/devel