staging: comedi: initialize subdevice s->io_bits in postconfig
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Fri, 30 Aug 2013 17:47:03 +0000 (10:47 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 17 Sep 2013 14:47:40 +0000 (07:47 -0700)
The subdevice 'io_bits' is a bit mask of the i/o configuration for
digital subdevices. '0' values indicate that a channel is configured
as an input and '1' values that the channel is an output. Since the
subdevice data is kzalloc()'d, all channels default as inputs.

Modify __comedi_device_postconfig() so that 'io_bits' is correctly
initialized for Digital Output subdevices.

Remove all the unnecessary initializations of 's->io_bits' from the
drivers. Also, remove the unnecessary initialization of the 's->state'.

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>
12 files changed:
drivers/staging/comedi/drivers.c
drivers/staging/comedi/drivers/8255.c
drivers/staging/comedi/drivers/addi-data/addi_common.c
drivers/staging/comedi/drivers/addi_apci_3120.c
drivers/staging/comedi/drivers/adl_pci6208.c
drivers/staging/comedi/drivers/adl_pci9118.c
drivers/staging/comedi/drivers/adv_pci1710.c
drivers/staging/comedi/drivers/amplc_dio200_common.c
drivers/staging/comedi/drivers/icp_multi.c
drivers/staging/comedi/drivers/me_daq.c
drivers/staging/comedi/drivers/ni_660x.c
drivers/staging/comedi/drivers/ni_daq_700.c

index 317a821b7906409a5fef8edd6a40b3360945300e..aeef59492ba2e5ba4b87637394d0c06ebe3cce86 100644 (file)
@@ -285,6 +285,13 @@ static int __comedi_device_postconfig(struct comedi_device *dev)
                if (s->type == COMEDI_SUBD_UNUSED)
                        continue;
 
+               if (s->type == COMEDI_SUBD_DO) {
+                       if (s->n_chan < 32)
+                               s->io_bits = (1 << s->n_chan) - 1;
+                       else
+                               s->io_bits = 0xffffffff;
+               }
+
                if (s->len_chanlist == 0)
                        s->len_chanlist = 1;
 
index 2f070fdbbb1d3b206b6e17f5f10bea0ec6e3a02a..5283bb520a1d379924ca40940223c3b477bea863 100644 (file)
@@ -288,9 +288,6 @@ int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s,
        s->insn_bits    = subdev_8255_insn;
        s->insn_config  = subdev_8255_insn_config;
 
-       s->state        = 0;
-       s->io_bits      = 0;
-
        subdev_8255_do_config(dev, s);
 
        return 0;
index 63dff7729ea893e8e76ce2fdcad61ca50ebb9d45..dc87df032203746418fa7274b36be42c38617d3a 100644 (file)
@@ -204,7 +204,6 @@ static int addi_auto_attach(struct comedi_device *dev,
                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;
@@ -223,7 +222,6 @@ static int addi_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 = this_board->do_config;
index d804957018aba8db2c0e95bd4f9d29a33ce8dfa0..67d09e8afb2efdbcf8c21677f884a135c59a5e8b 100644 (file)
@@ -164,7 +164,6 @@ static int apci3120_auto_attach(struct comedi_device *dev,
        s->maxdata = 1;
        s->len_chanlist = this_board->i_NbrDiChannel;
        s->range_table = &range_digital;
-       s->io_bits = 0; /* all bits input */
        s->insn_bits = apci3120_di_insn_bits;
 
        /*  Allocate and Initialise DO Subdevice Structures */
@@ -176,7 +175,6 @@ static int apci3120_auto_attach(struct comedi_device *dev,
        s->maxdata = this_board->i_DoMaxdata;
        s->len_chanlist = this_board->i_NbrDoChannel;
        s->range_table = &range_digital;
-       s->io_bits = 0xf;       /* all bits output */
        s->insn_bits = apci3120_do_insn_bits;
 
        /*  Allocate and Initialise Timer Subdevice Structures */
index a67ad57cefcb906c108f044cd2c3c069bc788418..28975061134b76ebfe34bff3316960a681ac45d1 100644 (file)
@@ -221,7 +221,6 @@ static int pci6208_auto_attach(struct comedi_device *dev,
        val = inw(dev->iobase + PCI6208_DIO);
        val = (val & PCI6208_DIO_DO_MASK) >> PCI6208_DIO_DO_SHIFT;
        s->state        = val;
-       s->io_bits      = 0x0f;
 
        dev_info(dev->class_dev, "%s: %s, I/O base=0x%04lx\n",
                dev->driver->driver_name, dev->board_name, dev->iobase);
index 22196ada0362200b12f83d89e9bed0dfa208e83d..7d2cff3eab8515c2572d092ec2dbc05095c1bff0 100644 (file)
@@ -2075,7 +2075,6 @@ static int pci9118_common_attach(struct comedi_device *dev, int disable_irq,
        s->maxdata = 1;
        s->len_chanlist = 4;
        s->range_table = &range_digital;
-       s->io_bits = 0;         /* all bits input */
        s->insn_bits = pci9118_insn_bits_di;
 
        s = &dev->subdevices[3];
@@ -2085,7 +2084,6 @@ static int pci9118_common_attach(struct comedi_device *dev, int disable_irq,
        s->maxdata = 1;
        s->len_chanlist = 4;
        s->range_table = &range_digital;
-       s->io_bits = 0xf;       /* all bits output */
        s->insn_bits = pci9118_insn_bits_do;
 
        devpriv->valid = 1;
index f84df46d326aeededa20d574bdcb8ae5b749a53f..fe087253c87046a5f1f4da819e50a46b37200beb 100644 (file)
@@ -1320,7 +1320,6 @@ static int pci1710_auto_attach(struct comedi_device *dev,
                s->maxdata = 1;
                s->len_chanlist = this_board->n_dichan;
                s->range_table = &range_digital;
-               s->io_bits = 0; /* all bits input */
                s->insn_bits = pci171x_insn_bits_di;
                subdev++;
        }
@@ -1333,9 +1332,6 @@ static int pci1710_auto_attach(struct comedi_device *dev,
                s->maxdata = 1;
                s->len_chanlist = this_board->n_dochan;
                s->range_table = &range_digital;
-               /* all bits output */
-               s->io_bits = (1 << this_board->n_dochan) - 1;
-               s->state = 0;
                s->insn_bits = pci171x_insn_bits_do;
                subdev++;
        }
index c1f723e8614613826d9753e07ec6af5044f925a7..8c6fa1e62abfe8e57a8976fc0b4a72e0ab32a8ef 100644 (file)
@@ -1022,8 +1022,6 @@ static int dio200_subdev_8255_init(struct comedi_device *dev,
        s->maxdata = 1;
        s->insn_bits = dio200_subdev_8255_bits;
        s->insn_config = dio200_subdev_8255_config;
-       s->state = 0;
-       s->io_bits = 0;
        dio200_subdev_8255_set_dir(dev, s);
        return 0;
 }
index 3889d23292d04d322dcba5d37dbf6d14c0a8aab0..17f9c066546977f31c3af795b532cc431e7f0703 100644 (file)
@@ -548,7 +548,6 @@ static int icp_multi_auto_attach(struct comedi_device *dev,
        s->maxdata = 1;
        s->len_chanlist = 16;
        s->range_table = &range_digital;
-       s->io_bits = 0;
        s->insn_bits = icp_multi_insn_bits_di;
 
        s = &dev->subdevices[3];
@@ -558,8 +557,6 @@ static int icp_multi_auto_attach(struct comedi_device *dev,
        s->maxdata = 1;
        s->len_chanlist = 8;
        s->range_table = &range_digital;
-       s->io_bits = 0xff;
-       s->state = 0;
        s->insn_bits = icp_multi_insn_bits_do;
 
        s = &dev->subdevices[4];
index a6f6d4a46587f06d1b84ba53a45df3ebcf150821..00ebf4dd78fb0f039233e9f825ee457e52f3a373 100644 (file)
@@ -545,7 +545,6 @@ static int me_auto_attach(struct comedi_device *dev,
        s->range_table  = &range_digital;
        s->insn_bits    = me_dio_insn_bits;
        s->insn_config  = me_dio_insn_config;
-       s->io_bits      = 0;
 
        dev_info(dev->class_dev, "%s: %s attached\n",
                dev->driver->driver_name, dev->board_name);
index 3607336dafe297968395871e00bd0a14fa700bd5..8a991dcab24a9b5a08cdcaf480979292337db555 100644 (file)
@@ -1213,7 +1213,6 @@ static int ni_660x_auto_attach(struct comedi_device *dev,
        s->range_table = &range_digital;
        s->insn_bits = ni_660x_dio_insn_bits;
        s->insn_config = ni_660x_dio_insn_config;
-       s->io_bits = 0;         /* all bits default to input */
        /*  we use the ioconfig registers to control dio direction, so zero
        output enables in stc dio control reg */
        ni_660x_write_register(dev, 0, 0, STCDIOControl);
index 404f83de276da21bd00cb4d17c7b87eb9fd9743d..0ac875f1878734bea1a57a45b0c69c49e49391e5 100644 (file)
@@ -212,7 +212,6 @@ static int daq700_auto_attach(struct comedi_device *dev,
        s->maxdata      = 1;
        s->insn_bits    = daq700_dio_insn_bits;
        s->insn_config  = daq700_dio_insn_config;
-       s->state        = 0;
        s->io_bits      = 0x00ff;
 
        /* DAQCard-700 ai */