[PATCH 08/35] staging: comedi: das1800: refactor 'resolution' boardinfo

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

 



The "hr" type boards have 16-bit analog inputs and outputs. All other board
types are 12-bit.

Replace the 'resolution' member of the boardinfo with a bit-field flag,
'is_16bit', and only set it for the 16-bit boards. Remove the unnecessary
initialization for the 12-bit boards.

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 drivers/staging/comedi/drivers/das1800.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c
index 324d1cc..6067b57 100644
--- a/drivers/staging/comedi/drivers/das1800.c
+++ b/drivers/staging/comedi/drivers/das1800.c
@@ -204,11 +204,11 @@ static const struct comedi_lrange range_ai_das1802 = {
 struct das1800_board {
 	const char *name;
 	int ai_speed;		/* max conversion period in nanoseconds */
-	int resolution;		/* bits of ai resolution */
 	int do_n_chan;		/* number of digital output channels */
 	int ao_ability;		/* 0 == no analog out, 1 == basic analog out, 2 == waveform analog out */
 	int ao_n_chan;		/* number of analog out channels */
 	const struct comedi_lrange *range_ai;	/* available input ranges */
+	unsigned int is_16bit:1;
 	unsigned int has_64_ai_chan:1;
 };
 
@@ -220,13 +220,11 @@ static const struct das1800_board das1800_boards[] = {
 	{
 		.name		= "das-1701st",
 		.ai_speed	= 6250,
-		.resolution	= 12,
 		.do_n_chan	= 4,
 		.range_ai	= &range_ai_das1801,
 	}, {
 		.name		= "das-1701st-da",
 		.ai_speed	= 6250,
-		.resolution	= 12,
 		.do_n_chan	= 4,
 		.ao_ability	= 1,
 		.ao_n_chan	= 4,
@@ -234,13 +232,11 @@ static const struct das1800_board das1800_boards[] = {
 	}, {
 		.name		= "das-1702st",
 		.ai_speed	= 6250,
-		.resolution	= 12,
 		.do_n_chan	= 4,
 		.range_ai	= &range_ai_das1802,
 	}, {
 		.name		= "das-1702st-da",
 		.ai_speed	= 6250,
-		.resolution	= 12,
 		.do_n_chan	= 4,
 		.ao_ability	= 1,
 		.ao_n_chan	= 4,
@@ -248,21 +244,20 @@ static const struct das1800_board das1800_boards[] = {
 	}, {
 		.name		= "das-1702hr",
 		.ai_speed	= 20000,
-		.resolution	= 16,
 		.do_n_chan	= 4,
 		.range_ai	= &range_ai_das1802,
+		.is_16bit	= 1,
 	}, {
 		.name		= "das-1702hr-da",
 		.ai_speed	= 20000,
-		.resolution	= 16,
 		.do_n_chan	= 4,
 		.ao_ability	= 1,
 		.ao_n_chan	= 2,
 		.range_ai	= &range_ai_das1802,
+		.is_16bit	= 1,
 	}, {
 		.name		= "das-1701ao",
 		.ai_speed	= 6250,
-		.resolution	= 12,
 		.do_n_chan	= 4,
 		.ao_ability	= 2,
 		.ao_n_chan	= 2,
@@ -270,7 +265,6 @@ static const struct das1800_board das1800_boards[] = {
 	}, {
 		.name		= "das-1702ao",
 		.ai_speed	= 6250,
-		.resolution	= 12,
 		.do_n_chan	= 4,
 		.ao_ability	= 2,
 		.ao_n_chan	= 2,
@@ -278,13 +272,11 @@ static const struct das1800_board das1800_boards[] = {
 	}, {
 		.name		= "das-1801st",
 		.ai_speed	= 3000,
-		.resolution	= 12,
 		.do_n_chan	= 4,
 		.range_ai	= &range_ai_das1801,
 	}, {
 		.name		= "das-1801st-da",
 		.ai_speed	= 3000,
-		.resolution	= 12,
 		.do_n_chan	= 4,
 		.ao_ability	= 1,
 		.ao_n_chan	= 4,
@@ -292,13 +284,11 @@ static const struct das1800_board das1800_boards[] = {
 	}, {
 		.name		= "das-1802st",
 		.ai_speed	= 3000,
-		.resolution	= 12,
 		.do_n_chan	= 4,
 		.range_ai	= &range_ai_das1802,
 	}, {
 		.name		= "das-1802st-da",
 		.ai_speed	= 3000,
-		.resolution	= 12,
 		.do_n_chan	= 4,
 		.ao_ability	= 1,
 		.ao_n_chan	= 4,
@@ -306,21 +296,20 @@ static const struct das1800_board das1800_boards[] = {
 	}, {
 		.name		= "das-1802hr",
 		.ai_speed	= 10000,
-		.resolution	= 16,
 		.do_n_chan	= 4,
 		.range_ai	= &range_ai_das1802,
+		.is_16bit	= 1,
 	}, {
 		.name		= "das-1802hr-da",
 		.ai_speed	= 10000,
-		.resolution	= 16,
 		.do_n_chan	= 4,
 		.ao_ability	= 1,
 		.ao_n_chan	= 2,
 		.range_ai	= &range_ai_das1802,
+		.is_16bit	= 1,
 	}, {
 		.name		= "das-1801hc",
 		.ai_speed	= 3000,
-		.resolution	= 12,
 		.do_n_chan	= 8,
 		.ao_ability	= 1,
 		.ao_n_chan	= 2,
@@ -329,7 +318,6 @@ static const struct das1800_board das1800_boards[] = {
 	}, {
 		.name		= "das-1802hc",
 		.ai_speed	= 3000,
-		.resolution	= 12,
 		.do_n_chan	= 8,
 		.ao_ability	= 1,
 		.ao_n_chan	= 2,
@@ -338,7 +326,6 @@ static const struct das1800_board das1800_boards[] = {
 	}, {
 		.name		= "das-1801ao",
 		.ai_speed	= 3000,
-		.resolution	= 12,
 		.do_n_chan	= 4,
 		.ao_ability	= 2,
 		.ao_n_chan	= 2,
@@ -346,7 +333,6 @@ static const struct das1800_board das1800_boards[] = {
 	}, {
 		.name		= "das-1802ao",
 		.ai_speed	= 3000,
-		.resolution	= 12,
 		.do_n_chan	= 4,
 		.ao_ability	= 2,
 		.ao_n_chan	= 2,
@@ -1296,7 +1282,7 @@ static int das1800_attach(struct comedi_device *dev,
 	if (!board->has_64_ai_chan)
 		s->subdev_flags	|= SDF_COMMON;
 	s->n_chan	= (board->has_64_ai_chan) ? 64 : 16;
-	s->maxdata	= (1 << board->resolution) - 1;
+	s->maxdata	= (board->is_16bit) ? 0xffff : 0x0fff;
 	s->range_table	= board->range_ai;
 	s->insn_read	= das1800_ai_insn_read;
 	if (dev->irq) {
@@ -1316,7 +1302,7 @@ static int das1800_attach(struct comedi_device *dev,
 		s->type		= COMEDI_SUBD_AO;
 		s->subdev_flags	= SDF_WRITABLE;
 		s->n_chan	= board->ao_n_chan;
-		s->maxdata	= (1 << board->resolution) - 1;
+		s->maxdata	= (board->is_16bit) ? 0xffff : 0x0fff;
 		s->range_table	= &range_bipolar10;
 		s->insn_write	= das1800_ao_insn_write;
 	} else {
-- 
2.6.3

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-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