Commit 09567cb4 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: initialize subdevice s->io_bits in postconfig

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: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent cb30fc50
...@@ -285,6 +285,13 @@ static int __comedi_device_postconfig(struct comedi_device *dev) ...@@ -285,6 +285,13 @@ static int __comedi_device_postconfig(struct comedi_device *dev)
if (s->type == COMEDI_SUBD_UNUSED) if (s->type == COMEDI_SUBD_UNUSED)
continue; 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) if (s->len_chanlist == 0)
s->len_chanlist = 1; s->len_chanlist = 1;
......
...@@ -288,9 +288,6 @@ int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s, ...@@ -288,9 +288,6 @@ int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s,
s->insn_bits = subdev_8255_insn; s->insn_bits = subdev_8255_insn;
s->insn_config = subdev_8255_insn_config; s->insn_config = subdev_8255_insn_config;
s->state = 0;
s->io_bits = 0;
subdev_8255_do_config(dev, s); subdev_8255_do_config(dev, s);
return 0; return 0;
......
...@@ -204,7 +204,6 @@ static int addi_auto_attach(struct comedi_device *dev, ...@@ -204,7 +204,6 @@ static int addi_auto_attach(struct comedi_device *dev,
s->len_chanlist = s->len_chanlist =
devpriv->s_EeParameters.i_NbrDiChannel; devpriv->s_EeParameters.i_NbrDiChannel;
s->range_table = &range_digital; s->range_table = &range_digital;
s->io_bits = 0; /* all bits input */
s->insn_config = this_board->di_config; s->insn_config = this_board->di_config;
s->insn_read = this_board->di_read; s->insn_read = this_board->di_read;
s->insn_write = this_board->di_write; s->insn_write = this_board->di_write;
...@@ -223,7 +222,6 @@ static int addi_auto_attach(struct comedi_device *dev, ...@@ -223,7 +222,6 @@ static int addi_auto_attach(struct comedi_device *dev,
s->len_chanlist = s->len_chanlist =
devpriv->s_EeParameters.i_NbrDoChannel; devpriv->s_EeParameters.i_NbrDoChannel;
s->range_table = &range_digital; s->range_table = &range_digital;
s->io_bits = 0xf; /* all bits output */
/* insn_config - for digital output memory */ /* insn_config - for digital output memory */
s->insn_config = this_board->do_config; s->insn_config = this_board->do_config;
......
...@@ -164,7 +164,6 @@ static int apci3120_auto_attach(struct comedi_device *dev, ...@@ -164,7 +164,6 @@ static int apci3120_auto_attach(struct comedi_device *dev,
s->maxdata = 1; s->maxdata = 1;
s->len_chanlist = this_board->i_NbrDiChannel; s->len_chanlist = this_board->i_NbrDiChannel;
s->range_table = &range_digital; s->range_table = &range_digital;
s->io_bits = 0; /* all bits input */
s->insn_bits = apci3120_di_insn_bits; s->insn_bits = apci3120_di_insn_bits;
/* Allocate and Initialise DO Subdevice Structures */ /* Allocate and Initialise DO Subdevice Structures */
...@@ -176,7 +175,6 @@ static int apci3120_auto_attach(struct comedi_device *dev, ...@@ -176,7 +175,6 @@ static int apci3120_auto_attach(struct comedi_device *dev,
s->maxdata = this_board->i_DoMaxdata; s->maxdata = this_board->i_DoMaxdata;
s->len_chanlist = this_board->i_NbrDoChannel; s->len_chanlist = this_board->i_NbrDoChannel;
s->range_table = &range_digital; s->range_table = &range_digital;
s->io_bits = 0xf; /* all bits output */
s->insn_bits = apci3120_do_insn_bits; s->insn_bits = apci3120_do_insn_bits;
/* Allocate and Initialise Timer Subdevice Structures */ /* Allocate and Initialise Timer Subdevice Structures */
......
...@@ -221,7 +221,6 @@ static int pci6208_auto_attach(struct comedi_device *dev, ...@@ -221,7 +221,6 @@ static int pci6208_auto_attach(struct comedi_device *dev,
val = inw(dev->iobase + PCI6208_DIO); val = inw(dev->iobase + PCI6208_DIO);
val = (val & PCI6208_DIO_DO_MASK) >> PCI6208_DIO_DO_SHIFT; val = (val & PCI6208_DIO_DO_MASK) >> PCI6208_DIO_DO_SHIFT;
s->state = val; s->state = val;
s->io_bits = 0x0f;
dev_info(dev->class_dev, "%s: %s, I/O base=0x%04lx\n", dev_info(dev->class_dev, "%s: %s, I/O base=0x%04lx\n",
dev->driver->driver_name, dev->board_name, dev->iobase); dev->driver->driver_name, dev->board_name, dev->iobase);
......
...@@ -2075,7 +2075,6 @@ static int pci9118_common_attach(struct comedi_device *dev, int disable_irq, ...@@ -2075,7 +2075,6 @@ static int pci9118_common_attach(struct comedi_device *dev, int disable_irq,
s->maxdata = 1; s->maxdata = 1;
s->len_chanlist = 4; s->len_chanlist = 4;
s->range_table = &range_digital; s->range_table = &range_digital;
s->io_bits = 0; /* all bits input */
s->insn_bits = pci9118_insn_bits_di; s->insn_bits = pci9118_insn_bits_di;
s = &dev->subdevices[3]; s = &dev->subdevices[3];
...@@ -2085,7 +2084,6 @@ static int pci9118_common_attach(struct comedi_device *dev, int disable_irq, ...@@ -2085,7 +2084,6 @@ static int pci9118_common_attach(struct comedi_device *dev, int disable_irq,
s->maxdata = 1; s->maxdata = 1;
s->len_chanlist = 4; s->len_chanlist = 4;
s->range_table = &range_digital; s->range_table = &range_digital;
s->io_bits = 0xf; /* all bits output */
s->insn_bits = pci9118_insn_bits_do; s->insn_bits = pci9118_insn_bits_do;
devpriv->valid = 1; devpriv->valid = 1;
......
...@@ -1320,7 +1320,6 @@ static int pci1710_auto_attach(struct comedi_device *dev, ...@@ -1320,7 +1320,6 @@ static int pci1710_auto_attach(struct comedi_device *dev,
s->maxdata = 1; s->maxdata = 1;
s->len_chanlist = this_board->n_dichan; s->len_chanlist = this_board->n_dichan;
s->range_table = &range_digital; s->range_table = &range_digital;
s->io_bits = 0; /* all bits input */
s->insn_bits = pci171x_insn_bits_di; s->insn_bits = pci171x_insn_bits_di;
subdev++; subdev++;
} }
...@@ -1333,9 +1332,6 @@ static int pci1710_auto_attach(struct comedi_device *dev, ...@@ -1333,9 +1332,6 @@ static int pci1710_auto_attach(struct comedi_device *dev,
s->maxdata = 1; s->maxdata = 1;
s->len_chanlist = this_board->n_dochan; s->len_chanlist = this_board->n_dochan;
s->range_table = &range_digital; 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; s->insn_bits = pci171x_insn_bits_do;
subdev++; subdev++;
} }
......
...@@ -1022,8 +1022,6 @@ static int dio200_subdev_8255_init(struct comedi_device *dev, ...@@ -1022,8 +1022,6 @@ static int dio200_subdev_8255_init(struct comedi_device *dev,
s->maxdata = 1; s->maxdata = 1;
s->insn_bits = dio200_subdev_8255_bits; s->insn_bits = dio200_subdev_8255_bits;
s->insn_config = dio200_subdev_8255_config; s->insn_config = dio200_subdev_8255_config;
s->state = 0;
s->io_bits = 0;
dio200_subdev_8255_set_dir(dev, s); dio200_subdev_8255_set_dir(dev, s);
return 0; return 0;
} }
......
...@@ -548,7 +548,6 @@ static int icp_multi_auto_attach(struct comedi_device *dev, ...@@ -548,7 +548,6 @@ static int icp_multi_auto_attach(struct comedi_device *dev,
s->maxdata = 1; s->maxdata = 1;
s->len_chanlist = 16; s->len_chanlist = 16;
s->range_table = &range_digital; s->range_table = &range_digital;
s->io_bits = 0;
s->insn_bits = icp_multi_insn_bits_di; s->insn_bits = icp_multi_insn_bits_di;
s = &dev->subdevices[3]; s = &dev->subdevices[3];
...@@ -558,8 +557,6 @@ static int icp_multi_auto_attach(struct comedi_device *dev, ...@@ -558,8 +557,6 @@ static int icp_multi_auto_attach(struct comedi_device *dev,
s->maxdata = 1; s->maxdata = 1;
s->len_chanlist = 8; s->len_chanlist = 8;
s->range_table = &range_digital; s->range_table = &range_digital;
s->io_bits = 0xff;
s->state = 0;
s->insn_bits = icp_multi_insn_bits_do; s->insn_bits = icp_multi_insn_bits_do;
s = &dev->subdevices[4]; s = &dev->subdevices[4];
......
...@@ -545,7 +545,6 @@ static int me_auto_attach(struct comedi_device *dev, ...@@ -545,7 +545,6 @@ static int me_auto_attach(struct comedi_device *dev,
s->range_table = &range_digital; s->range_table = &range_digital;
s->insn_bits = me_dio_insn_bits; s->insn_bits = me_dio_insn_bits;
s->insn_config = me_dio_insn_config; s->insn_config = me_dio_insn_config;
s->io_bits = 0;
dev_info(dev->class_dev, "%s: %s attached\n", dev_info(dev->class_dev, "%s: %s attached\n",
dev->driver->driver_name, dev->board_name); dev->driver->driver_name, dev->board_name);
......
...@@ -1213,7 +1213,6 @@ static int ni_660x_auto_attach(struct comedi_device *dev, ...@@ -1213,7 +1213,6 @@ static int ni_660x_auto_attach(struct comedi_device *dev,
s->range_table = &range_digital; s->range_table = &range_digital;
s->insn_bits = ni_660x_dio_insn_bits; s->insn_bits = ni_660x_dio_insn_bits;
s->insn_config = ni_660x_dio_insn_config; 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 /* we use the ioconfig registers to control dio direction, so zero
output enables in stc dio control reg */ output enables in stc dio control reg */
ni_660x_write_register(dev, 0, 0, STCDIOControl); ni_660x_write_register(dev, 0, 0, STCDIOControl);
......
...@@ -212,7 +212,6 @@ static int daq700_auto_attach(struct comedi_device *dev, ...@@ -212,7 +212,6 @@ static int daq700_auto_attach(struct comedi_device *dev,
s->maxdata = 1; s->maxdata = 1;
s->insn_bits = daq700_dio_insn_bits; s->insn_bits = daq700_dio_insn_bits;
s->insn_config = daq700_dio_insn_config; s->insn_config = daq700_dio_insn_config;
s->state = 0;
s->io_bits = 0x00ff; s->io_bits = 0x00ff;
/* DAQCard-700 ai */ /* DAQCard-700 ai */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment