staging: comedi: addi_apci_3501: cleanup the digital input subdevice
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Wed, 23 Jan 2013 19:37:38 +0000 (12:37 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 25 Jan 2013 20:00:27 +0000 (12:00 -0800)
The board supported by this driver has 2 digital input. Remove the
conditional and always init the subdevice.

Also, move the subdevice insn_bits function pointer as well as the
n_chan out of the boardinfo and use them to initialize the subdevice
directly.

Since devpriv->s_EeParameters.i_NbrDiChannel for the digital input
subdevice is no longer being used, remove initialization of it also.

Copy the apci3501_di_insn_bits() function from hwrdv_apci3501.c into
the main driver file.

Fix the subdev_flags for the subdevice. The only required flag is
SDF_READABLE. The SDF_GROUND and SDF_COMMON flags only have meaning
for analog subdevices.

Remove the len_chanlist initialization, it only has meaning for subdevices
that support commands.

Remove the io_bits initialization, it only has meaning for digital i/o
subdevices that have configurable outputs.

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_apci3501.c
drivers/staging/comedi/drivers/addi_apci_3501.c

index c7abe85c59f70966a6fa90b6f2a0925e4cf6736b..4ecdb9e20f4f585465d2f7e1eea73a14c60d368c 100644 (file)
@@ -84,18 +84,6 @@ static struct comedi_lrange range_apci3501_ao = {
        }
 };
 
-static int apci3501_di_insn_bits(struct comedi_device *dev,
-                                struct comedi_subdevice *s,
-                                struct comedi_insn *insn,
-                                unsigned int *data)
-{
-       struct addi_private *devpriv = dev->private;
-
-       data[1] = inl(devpriv->iobase + APCI3501_DIGITAL_IP) & 0x3;
-
-       return insn->n;
-}
-
 /*
 +----------------------------------------------------------------------------+
 | Function   Name   : int i_APCI3501_ConfigAnalogOutput                      |
index 8ea3838165bffa7e74de1b582bd62492764f35e1..fa2b2352062e01cd5046e1ca20a4391b6fcc5fc0 100644 (file)
@@ -18,15 +18,25 @@ static const struct addi_board apci3501_boardtypes[] = {
                .pc_EepromChip          = ADDIDATA_S5933,
                .i_AoMaxdata            = 16383,
                .pr_AoRangelist         = &range_apci3501_ao,
-               .i_NbrDiChannel         = 2,
                .interrupt              = v_APCI3501_Interrupt,
                .reset                  = i_APCI3501_Reset,
                .ao_config              = i_APCI3501_ConfigAnalogOutput,
                .ao_write               = i_APCI3501_WriteAnalogOutput,
-               .di_bits                = apci3501_di_insn_bits,
        },
 };
 
+static int apci3501_di_insn_bits(struct comedi_device *dev,
+                                struct comedi_subdevice *s,
+                                struct comedi_insn *insn,
+                                unsigned int *data)
+{
+       struct addi_private *devpriv = dev->private;
+
+       data[1] = inl(devpriv->iobase + APCI3501_DIGITAL_IP) & 0x3;
+
+       return insn->n;
+}
+
 static int apci3501_do_insn_bits(struct comedi_device *dev,
                                 struct comedi_subdevice *s,
                                 struct comedi_insn *insn,
@@ -150,7 +160,6 @@ static int apci3501_auto_attach(struct comedi_device *dev,
        devpriv->s_EeParameters.i_NbrAoChannel = this_board->i_NbrAoChannel;
        devpriv->s_EeParameters.i_AiMaxdata = this_board->i_AiMaxdata;
        devpriv->s_EeParameters.i_AoMaxdata = this_board->i_AoMaxdata;
-       devpriv->s_EeParameters.i_NbrDiChannel = this_board->i_NbrDiChannel;
        devpriv->s_EeParameters.i_Dma = this_board->i_Dma;
        devpriv->s_EeParameters.ui_MinAcquisitiontimeNs =
                this_board->ui_MinAcquisitiontimeNs;
@@ -241,22 +250,12 @@ static int apci3501_auto_attach(struct comedi_device *dev,
        }
        /*  Allocate and Initialise DI Subdevice Structures */
        s = &dev->subdevices[2];
-       if (devpriv->s_EeParameters.i_NbrDiChannel) {
-               s->type = COMEDI_SUBD_DI;
-               s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON;
-               s->n_chan = devpriv->s_EeParameters.i_NbrDiChannel;
-               s->maxdata = 1;
-               s->len_chanlist =
-                       devpriv->s_EeParameters.i_NbrDiChannel;
-               s->range_table = &range_digital;
-               s->io_bits = 0; /* all bits input */
-               s->insn_config = this_board->di_config;
-               s->insn_read = this_board->di_read;
-               s->insn_write = this_board->di_write;
-               s->insn_bits = this_board->di_bits;
-       } else {
-               s->type = COMEDI_SUBD_UNUSED;
-       }
+       s->type         = COMEDI_SUBD_DI;
+       s->subdev_flags = SDF_READABLE;
+       s->n_chan       = 2;
+       s->maxdata      = 1;
+       s->range_table  = &range_digital;
+       s->insn_bits    = apci3501_di_insn_bits;
 
        /* Initialize the digital output subdevice */
        s = &dev->subdevices[3];