From ffd76b327a19b49696635cd6891b9d279a73623e Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 31 Aug 2012 20:41:32 +0100 Subject: [PATCH] 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: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 16 +++++++++++++++- drivers/staging/comedi/drivers/das08.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 33279dc1430d..d176b3bd551c 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -502,6 +502,7 @@ static const struct das08_board_struct das08_boards[] = { .ao = NULL, .ao_nbits = 12, .di = das08_di_rbits, + .di_nchan = 3, .do_ = das08_do_wbits, .do_nchan = 4, .i8255_offset = 8, @@ -517,6 +518,7 @@ static const struct das08_board_struct das08_boards[] = { .ai_encoding = das08_encode12, .ao = NULL, .di = das08_di_rbits, + .di_nchan = 3, .do_ = das08_do_wbits, .do_nchan = 4, .i8255_offset = 0, @@ -532,6 +534,7 @@ static const struct das08_board_struct das08_boards[] = { .ai_encoding = das08_encode12, .ao = NULL, .di = das08_di_rbits, + .di_nchan = 3, .do_ = das08_do_wbits, .do_nchan = 4, .i8255_offset = 0, @@ -547,6 +550,7 @@ static const struct das08_board_struct das08_boards[] = { .ai_encoding = das08_encode12, .ao = NULL, .di = das08_di_rbits, + .di_nchan = 3, .do_ = das08_do_wbits, .do_nchan = 4, .i8255_offset = 0, @@ -563,6 +567,7 @@ static const struct das08_board_struct das08_boards[] = { .ao = das08ao_ao_winsn, /* 8 */ .ao_nbits = 12, .di = das08_di_rbits, + .di_nchan = 3, .do_ = das08_do_wbits, .do_nchan = 4, .i8255_offset = 0x0c, @@ -579,6 +584,7 @@ static const struct das08_board_struct das08_boards[] = { .ao = das08ao_ao_winsn, /* 8 */ .ao_nbits = 12, .di = das08_di_rbits, + .di_nchan = 3, .do_ = das08_do_wbits, .do_nchan = 4, .i8255_offset = 0x0c, @@ -595,6 +601,7 @@ static const struct das08_board_struct das08_boards[] = { .ao = das08ao_ao_winsn, /* 8 */ .ao_nbits = 12, .di = das08_di_rbits, + .di_nchan = 3, .do_ = das08_do_wbits, .do_nchan = 4, .i8255_offset = 0x0c, @@ -611,6 +618,7 @@ static const struct das08_board_struct das08_boards[] = { .ao = das08jr_ao_winsn, .ao_nbits = 12, .di = das08jr_di_rbits, + .di_nchan = 8, .do_ = das08jr_do_wbits, .do_nchan = 8, .i8255_offset = 0, @@ -627,6 +635,7 @@ static const struct das08_board_struct das08_boards[] = { .ao = das08jr_ao_winsn, .ao_nbits = 16, .di = das08jr_di_rbits, + .di_nchan = 8, .do_ = das08jr_do_wbits, .do_nchan = 8, .i8255_offset = 0, @@ -643,6 +652,7 @@ static const struct das08_board_struct das08_boards[] = { .ao = NULL, .ao_nbits = 0, .di = das08_di_rbits, + .di_nchan = 3, .do_ = das08_do_wbits, .do_nchan = 4, .i8255_offset = 0, @@ -667,6 +677,7 @@ static const struct das08_board_struct das08_boards[] = { .ao = NULL, .ao_nbits = 0, .di = das08jr_di_rbits, + .di_nchan = 8, .do_ = das08jr_do_wbits, .do_nchan = 8, .i8255_offset = 0, @@ -694,6 +705,7 @@ static const struct das08_board_struct das08_boards[] = { .ao = NULL, .ao_nbits = 0, .di = das08_di_rbits, + .di_nchan = 3, .do_ = das08_do_wbits, .do_nchan = 4, .i8255_offset = 0, @@ -722,6 +734,7 @@ struct das08_board_struct das08_cs_boards[NUM_DAS08_CS_BOARDS] = { .ao = NULL, .ao_nbits = 0, .di = das08_di_rbits, + .di_nchan = 3, .do_ = das08_do_wbits, .do_nchan = 3, .i8255_offset = 0, @@ -740,6 +753,7 @@ struct das08_board_struct das08_cs_boards[NUM_DAS08_CS_BOARDS] = { .ao = NULL, .ao_nbits = 0, .di = das08_di_rbits, + .di_nchan = 3, .do_ = das08_do_wbits, .do_nchan = 3, .i8255_offset = 0, @@ -803,7 +817,7 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) if (thisboard->di) { s->type = COMEDI_SUBD_DI; 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->range_table = &range_digital; s->insn_bits = thisboard->di; diff --git a/drivers/staging/comedi/drivers/das08.h b/drivers/staging/comedi/drivers/das08.h index f80913e2c41c..320f56aa3148 100644 --- a/drivers/staging/comedi/drivers/das08.h +++ b/drivers/staging/comedi/drivers/das08.h @@ -42,6 +42,7 @@ struct das08_board_struct { void *ao; unsigned int ao_nbits; void *di; + unsigned int di_nchan; void *do_; unsigned int do_nchan; unsigned int i8255_offset; -- 2.30.2