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: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Родитель
cb30fc50fe
Коммит
09567cb437
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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++;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 */
|
||||
|
|
Загрузка…
Ссылка в новой задаче