[PATCH 04/21] staging: comedi: das08: Add number of DI channels in board structure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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 1705206..9d45103 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 f80913e..320f56a 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;
-- 
1.7.12

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux