Skip to content

Commit

Permalink
staging: comedi: das08: Add number of DI channels in board structure
Browse files Browse the repository at this point in the history
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 <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Ian Abbott authored and Greg Kroah-Hartman committed Sep 4, 2012
1 parent 4865a47 commit ffd76b3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 15 additions & 1 deletion drivers/staging/comedi/drivers/das08.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions drivers/staging/comedi/drivers/das08.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ffd76b3

Please sign in to comment.