staging: comedi: das08: Add number of DI channels in board structure
authorIan Abbott <abbotti@mev.co.uk>
Fri, 31 Aug 2012 19:41:32 +0000 (20:41 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 4 Sep 2012 19:00:41 +0000 (12:00 -0700)
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>
drivers/staging/comedi/drivers/das08.c
drivers/staging/comedi/drivers/das08.h

index 33279dc1430d808b172e33161ea7f125ede984c9..d176b3bd551c4da05ba5fd8e946d49a9d6a70d91 100644 (file)
@@ -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;
index f80913e2c41c7820818d4256249e42b16bbdf8a9..320f56aa31485e9f5fca38580ce37fb0024ea62b 100644 (file)
@@ -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;