Commit ffd76b32 authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman

staging: comedi: das08: Add number of DI channels in board structure

Add member `di_nchan` to `struct das08_board_struct` to set the number
of digital input channels explicitly.  Currently, the code determines
the number of channels to 3 or 8 depending on what function the `di`
member points to, which is not very elegant.
Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4865a47f
...@@ -502,6 +502,7 @@ static const struct das08_board_struct das08_boards[] = { ...@@ -502,6 +502,7 @@ static const struct das08_board_struct das08_boards[] = {
.ao = NULL, .ao = NULL,
.ao_nbits = 12, .ao_nbits = 12,
.di = das08_di_rbits, .di = das08_di_rbits,
.di_nchan = 3,
.do_ = das08_do_wbits, .do_ = das08_do_wbits,
.do_nchan = 4, .do_nchan = 4,
.i8255_offset = 8, .i8255_offset = 8,
...@@ -517,6 +518,7 @@ static const struct das08_board_struct das08_boards[] = { ...@@ -517,6 +518,7 @@ static const struct das08_board_struct das08_boards[] = {
.ai_encoding = das08_encode12, .ai_encoding = das08_encode12,
.ao = NULL, .ao = NULL,
.di = das08_di_rbits, .di = das08_di_rbits,
.di_nchan = 3,
.do_ = das08_do_wbits, .do_ = das08_do_wbits,
.do_nchan = 4, .do_nchan = 4,
.i8255_offset = 0, .i8255_offset = 0,
...@@ -532,6 +534,7 @@ static const struct das08_board_struct das08_boards[] = { ...@@ -532,6 +534,7 @@ static const struct das08_board_struct das08_boards[] = {
.ai_encoding = das08_encode12, .ai_encoding = das08_encode12,
.ao = NULL, .ao = NULL,
.di = das08_di_rbits, .di = das08_di_rbits,
.di_nchan = 3,
.do_ = das08_do_wbits, .do_ = das08_do_wbits,
.do_nchan = 4, .do_nchan = 4,
.i8255_offset = 0, .i8255_offset = 0,
...@@ -547,6 +550,7 @@ static const struct das08_board_struct das08_boards[] = { ...@@ -547,6 +550,7 @@ static const struct das08_board_struct das08_boards[] = {
.ai_encoding = das08_encode12, .ai_encoding = das08_encode12,
.ao = NULL, .ao = NULL,
.di = das08_di_rbits, .di = das08_di_rbits,
.di_nchan = 3,
.do_ = das08_do_wbits, .do_ = das08_do_wbits,
.do_nchan = 4, .do_nchan = 4,
.i8255_offset = 0, .i8255_offset = 0,
...@@ -563,6 +567,7 @@ static const struct das08_board_struct das08_boards[] = { ...@@ -563,6 +567,7 @@ static const struct das08_board_struct das08_boards[] = {
.ao = das08ao_ao_winsn, /* 8 */ .ao = das08ao_ao_winsn, /* 8 */
.ao_nbits = 12, .ao_nbits = 12,
.di = das08_di_rbits, .di = das08_di_rbits,
.di_nchan = 3,
.do_ = das08_do_wbits, .do_ = das08_do_wbits,
.do_nchan = 4, .do_nchan = 4,
.i8255_offset = 0x0c, .i8255_offset = 0x0c,
...@@ -579,6 +584,7 @@ static const struct das08_board_struct das08_boards[] = { ...@@ -579,6 +584,7 @@ static const struct das08_board_struct das08_boards[] = {
.ao = das08ao_ao_winsn, /* 8 */ .ao = das08ao_ao_winsn, /* 8 */
.ao_nbits = 12, .ao_nbits = 12,
.di = das08_di_rbits, .di = das08_di_rbits,
.di_nchan = 3,
.do_ = das08_do_wbits, .do_ = das08_do_wbits,
.do_nchan = 4, .do_nchan = 4,
.i8255_offset = 0x0c, .i8255_offset = 0x0c,
...@@ -595,6 +601,7 @@ static const struct das08_board_struct das08_boards[] = { ...@@ -595,6 +601,7 @@ static const struct das08_board_struct das08_boards[] = {
.ao = das08ao_ao_winsn, /* 8 */ .ao = das08ao_ao_winsn, /* 8 */
.ao_nbits = 12, .ao_nbits = 12,
.di = das08_di_rbits, .di = das08_di_rbits,
.di_nchan = 3,
.do_ = das08_do_wbits, .do_ = das08_do_wbits,
.do_nchan = 4, .do_nchan = 4,
.i8255_offset = 0x0c, .i8255_offset = 0x0c,
...@@ -611,6 +618,7 @@ static const struct das08_board_struct das08_boards[] = { ...@@ -611,6 +618,7 @@ static const struct das08_board_struct das08_boards[] = {
.ao = das08jr_ao_winsn, .ao = das08jr_ao_winsn,
.ao_nbits = 12, .ao_nbits = 12,
.di = das08jr_di_rbits, .di = das08jr_di_rbits,
.di_nchan = 8,
.do_ = das08jr_do_wbits, .do_ = das08jr_do_wbits,
.do_nchan = 8, .do_nchan = 8,
.i8255_offset = 0, .i8255_offset = 0,
...@@ -627,6 +635,7 @@ static const struct das08_board_struct das08_boards[] = { ...@@ -627,6 +635,7 @@ static const struct das08_board_struct das08_boards[] = {
.ao = das08jr_ao_winsn, .ao = das08jr_ao_winsn,
.ao_nbits = 16, .ao_nbits = 16,
.di = das08jr_di_rbits, .di = das08jr_di_rbits,
.di_nchan = 8,
.do_ = das08jr_do_wbits, .do_ = das08jr_do_wbits,
.do_nchan = 8, .do_nchan = 8,
.i8255_offset = 0, .i8255_offset = 0,
...@@ -643,6 +652,7 @@ static const struct das08_board_struct das08_boards[] = { ...@@ -643,6 +652,7 @@ static const struct das08_board_struct das08_boards[] = {
.ao = NULL, .ao = NULL,
.ao_nbits = 0, .ao_nbits = 0,
.di = das08_di_rbits, .di = das08_di_rbits,
.di_nchan = 3,
.do_ = das08_do_wbits, .do_ = das08_do_wbits,
.do_nchan = 4, .do_nchan = 4,
.i8255_offset = 0, .i8255_offset = 0,
...@@ -667,6 +677,7 @@ static const struct das08_board_struct das08_boards[] = { ...@@ -667,6 +677,7 @@ static const struct das08_board_struct das08_boards[] = {
.ao = NULL, .ao = NULL,
.ao_nbits = 0, .ao_nbits = 0,
.di = das08jr_di_rbits, .di = das08jr_di_rbits,
.di_nchan = 8,
.do_ = das08jr_do_wbits, .do_ = das08jr_do_wbits,
.do_nchan = 8, .do_nchan = 8,
.i8255_offset = 0, .i8255_offset = 0,
...@@ -694,6 +705,7 @@ static const struct das08_board_struct das08_boards[] = { ...@@ -694,6 +705,7 @@ static const struct das08_board_struct das08_boards[] = {
.ao = NULL, .ao = NULL,
.ao_nbits = 0, .ao_nbits = 0,
.di = das08_di_rbits, .di = das08_di_rbits,
.di_nchan = 3,
.do_ = das08_do_wbits, .do_ = das08_do_wbits,
.do_nchan = 4, .do_nchan = 4,
.i8255_offset = 0, .i8255_offset = 0,
...@@ -722,6 +734,7 @@ struct das08_board_struct das08_cs_boards[NUM_DAS08_CS_BOARDS] = { ...@@ -722,6 +734,7 @@ struct das08_board_struct das08_cs_boards[NUM_DAS08_CS_BOARDS] = {
.ao = NULL, .ao = NULL,
.ao_nbits = 0, .ao_nbits = 0,
.di = das08_di_rbits, .di = das08_di_rbits,
.di_nchan = 3,
.do_ = das08_do_wbits, .do_ = das08_do_wbits,
.do_nchan = 3, .do_nchan = 3,
.i8255_offset = 0, .i8255_offset = 0,
...@@ -740,6 +753,7 @@ struct das08_board_struct das08_cs_boards[NUM_DAS08_CS_BOARDS] = { ...@@ -740,6 +753,7 @@ struct das08_board_struct das08_cs_boards[NUM_DAS08_CS_BOARDS] = {
.ao = NULL, .ao = NULL,
.ao_nbits = 0, .ao_nbits = 0,
.di = das08_di_rbits, .di = das08_di_rbits,
.di_nchan = 3,
.do_ = das08_do_wbits, .do_ = das08_do_wbits,
.do_nchan = 3, .do_nchan = 3,
.i8255_offset = 0, .i8255_offset = 0,
...@@ -803,7 +817,7 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) ...@@ -803,7 +817,7 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase)
if (thisboard->di) { if (thisboard->di) {
s->type = COMEDI_SUBD_DI; s->type = COMEDI_SUBD_DI;
s->subdev_flags = SDF_READABLE; s->subdev_flags = SDF_READABLE;
s->n_chan = (thisboard->di == das08_di_rbits) ? 3 : 8; s->n_chan = thisboard->di_nchan;
s->maxdata = 1; s->maxdata = 1;
s->range_table = &range_digital; s->range_table = &range_digital;
s->insn_bits = thisboard->di; s->insn_bits = thisboard->di;
......
...@@ -42,6 +42,7 @@ struct das08_board_struct { ...@@ -42,6 +42,7 @@ struct das08_board_struct {
void *ao; void *ao;
unsigned int ao_nbits; unsigned int ao_nbits;
void *di; void *di;
unsigned int di_nchan;
void *do_; void *do_;
unsigned int do_nchan; unsigned int do_nchan;
unsigned int i8255_offset; unsigned int i8255_offset;
......
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