staging: comedi: addi_apci_3xxx: absorb apci3xxx_do_insn_bits()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Wed, 12 Jun 2013 23:05:13 +0000 (16:05 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 17 Jun 2013 21:33:38 +0000 (14:33 -0700)
All the boards supported by this driver that have digital outputs use
the same 'do_bits' callback in the boardinfo. Absorb the function from
hwdrv_apci3xxx.c directly into the driver.

Remove the 'do_bits' callback from the boardinfo and use the function
directly to set the subdevice (*insn_bits).

None of the boards supported by this driver have a 'do_config', 'do_write',
or 'do_read' callback. Remove the unnecessary setting of the subdevice
callbacks.

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>
drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c
drivers/staging/comedi/drivers/addi_apci_3xxx.c

index 02a6fcc..383b70e 100644 (file)
@@ -1283,25 +1283,3 @@ static int apci3xxx_di_insn_bits(struct comedi_device *dev,
 
        return insn->n;
 }
-
-static int apci3xxx_do_insn_bits(struct comedi_device *dev,
-                                struct comedi_subdevice *s,
-                                struct comedi_insn *insn,
-                                unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-       unsigned int mask = data[0];
-       unsigned int bits = data[1];
-
-       s->state = inl(devpriv->iobase + 48) & 0xf;
-       if (mask) {
-               s->state &= ~mask;
-               s->state |= (bits & mask);
-
-               outl(s->state, devpriv->iobase + 48);
-       }
-
-       data[1] = s->state;
-
-       return insn->n;
-}
index 7ec4132..f2ebce0 100644 (file)
@@ -188,7 +188,6 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ai_config              = i_APCI3XXX_InsnConfigAnalogInput,
                .ai_read                = i_APCI3XXX_InsnReadAnalogInput,
                .di_bits                = apci3xxx_di_insn_bits,
-               .do_bits                = apci3xxx_do_insn_bits,
                .ttl_config             = i_APCI3XXX_InsnConfigInitTTLIO,
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
@@ -214,7 +213,6 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ai_config              = i_APCI3XXX_InsnConfigAnalogInput,
                .ai_read                = i_APCI3XXX_InsnReadAnalogInput,
                .di_bits                = apci3xxx_di_insn_bits,
-               .do_bits                = apci3xxx_do_insn_bits,
                .ttl_config             = i_APCI3XXX_InsnConfigInitTTLIO,
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
@@ -240,7 +238,6 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ai_config              = i_APCI3XXX_InsnConfigAnalogInput,
                .ai_read                = i_APCI3XXX_InsnReadAnalogInput,
                .di_bits                = apci3xxx_di_insn_bits,
-               .do_bits                = apci3xxx_do_insn_bits,
                .ttl_config             = i_APCI3XXX_InsnConfigInitTTLIO,
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
@@ -266,7 +263,6 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ai_config              = i_APCI3XXX_InsnConfigAnalogInput,
                .ai_read                = i_APCI3XXX_InsnReadAnalogInput,
                .di_bits                = apci3xxx_di_insn_bits,
-               .do_bits                = apci3xxx_do_insn_bits,
                .ttl_config             = i_APCI3XXX_InsnConfigInitTTLIO,
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
@@ -292,7 +288,6 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ai_config              = i_APCI3XXX_InsnConfigAnalogInput,
                .ai_read                = i_APCI3XXX_InsnReadAnalogInput,
                .di_bits                = apci3xxx_di_insn_bits,
-               .do_bits                = apci3xxx_do_insn_bits,
                .ttl_config             = i_APCI3XXX_InsnConfigInitTTLIO,
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
@@ -318,7 +313,6 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ai_config              = i_APCI3XXX_InsnConfigAnalogInput,
                .ai_read                = i_APCI3XXX_InsnReadAnalogInput,
                .di_bits                = apci3xxx_di_insn_bits,
-               .do_bits                = apci3xxx_do_insn_bits,
                .ttl_config             = i_APCI3XXX_InsnConfigInitTTLIO,
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
@@ -448,7 +442,6 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ai_read                = i_APCI3XXX_InsnReadAnalogInput,
                .ao_write               = i_APCI3XXX_InsnWriteAnalogOutput,
                .di_bits                = apci3xxx_di_insn_bits,
-               .do_bits                = apci3xxx_do_insn_bits,
                .ttl_config             = i_APCI3XXX_InsnConfigInitTTLIO,
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
@@ -478,7 +471,6 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ai_read                = i_APCI3XXX_InsnReadAnalogInput,
                .ao_write               = i_APCI3XXX_InsnWriteAnalogOutput,
                .di_bits                = apci3xxx_di_insn_bits,
-               .do_bits                = apci3xxx_do_insn_bits,
                .ttl_config             = i_APCI3XXX_InsnConfigInitTTLIO,
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
@@ -508,7 +500,6 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ai_read                = i_APCI3XXX_InsnReadAnalogInput,
                .ao_write               = i_APCI3XXX_InsnWriteAnalogOutput,
                .di_bits                = apci3xxx_di_insn_bits,
-               .do_bits                = apci3xxx_do_insn_bits,
                .ttl_config             = i_APCI3XXX_InsnConfigInitTTLIO,
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
@@ -538,7 +529,6 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ai_read                = i_APCI3XXX_InsnReadAnalogInput,
                .ao_write               = i_APCI3XXX_InsnWriteAnalogOutput,
                .di_bits                = apci3xxx_di_insn_bits,
-               .do_bits                = apci3xxx_do_insn_bits,
                .ttl_config             = i_APCI3XXX_InsnConfigInitTTLIO,
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
@@ -562,7 +552,6 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ai_config              = i_APCI3XXX_InsnConfigAnalogInput,
                .ai_read                = i_APCI3XXX_InsnReadAnalogInput,
                .di_bits                = apci3xxx_di_insn_bits,
-               .do_bits                = apci3xxx_do_insn_bits,
        },
        [BOARD_APCI3002_16] = {
                .pc_DriverName          = "apci3002-16",
@@ -582,7 +571,6 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ai_config              = i_APCI3XXX_InsnConfigAnalogInput,
                .ai_read                = i_APCI3XXX_InsnReadAnalogInput,
                .di_bits                = apci3xxx_di_insn_bits,
-               .do_bits                = apci3xxx_do_insn_bits,
        },
        [BOARD_APCI3002_8] = {
                .pc_DriverName          = "apci3002-8",
@@ -602,7 +590,6 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ai_config              = i_APCI3XXX_InsnConfigAnalogInput,
                .ai_read                = i_APCI3XXX_InsnReadAnalogInput,
                .di_bits                = apci3xxx_di_insn_bits,
-               .do_bits                = apci3xxx_do_insn_bits,
        },
        [BOARD_APCI3002_4] = {
                .pc_DriverName          = "apci3002-4",
@@ -622,7 +609,6 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ai_config              = i_APCI3XXX_InsnConfigAnalogInput,
                .ai_read                = i_APCI3XXX_InsnReadAnalogInput,
                .di_bits                = apci3xxx_di_insn_bits,
-               .do_bits                = apci3xxx_do_insn_bits,
        },
        [BOARD_APCI3500] = {
                .pc_DriverName          = "apci3500",
@@ -642,6 +628,28 @@ static const struct addi_board apci3xxx_boardtypes[] = {
        },
 };
 
+static int apci3xxx_do_insn_bits(struct comedi_device *dev,
+                                struct comedi_subdevice *s,
+                                struct comedi_insn *insn,
+                                unsigned int *data)
+{
+       struct addi_private *devpriv = dev->private;
+       unsigned int mask = data[0];
+       unsigned int bits = data[1];
+
+       s->state = inl(devpriv->iobase + 48) & 0xf;
+       if (mask) {
+               s->state &= ~mask;
+               s->state |= (bits & mask);
+
+               outl(s->state, devpriv->iobase + 48);
+       }
+
+       data[1] = s->state;
+
+       return insn->n;
+}
+
 static int i_ADDIDATA_InsnReadEeprom(struct comedi_device *dev,
                                     struct comedi_subdevice *s,
                                     struct comedi_insn *insn,
@@ -866,12 +874,7 @@ static int apci3xxx_auto_attach(struct comedi_device *dev,
                s->len_chanlist = devpriv->s_EeParameters.i_NbrDoChannel;
                s->range_table = &range_digital;
                s->io_bits = 0xf;       /* all bits output */
-
-               /* insn_config - for digital output memory */
-               s->insn_config = board->do_config;
-               s->insn_write = board->do_write;
-               s->insn_bits = board->do_bits;
-               s->insn_read = board->do_read;
+               s->insn_bits = apci3xxx_do_insn_bits;
        } else {
                s->type = COMEDI_SUBD_UNUSED;
        }