]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: comedi: addi_apci_3xxx: fix digital input 'insn_bits' function
authorH Hartley Sweeten <hartleys@visionengravers.com>
Tue, 6 Nov 2012 17:01:26 +0000 (10:01 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 13 Nov 2012 19:21:37 +0000 (11:21 -0800)
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>
drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c
drivers/staging/comedi/drivers/addi_apci_3xxx.c

index d1b0ee6b628f4b9c365162f33feae55569fd61ed..5d3570c8a1cbd4da1dac1f7d8db817d790831c88 100644 (file)
@@ -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;
 }
 
 /*
index 00c972e140f7d6094a304f8257d079cddd8ab92f..d0cd2e8544ba32bbca4fa34c509640914eaa1a30 100644 (file)
@@ -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,