[PATCH 10/35] staging: comedi: das1800: refactor 'ao_ability' boardinfo

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

 



The "da" and "hc" type boards have normal analog outputs. The "ao"
type boards have move advanced analog outputs with waveform generation
capability.

Replace the 'ao_ability' member of the boardinfo with some bit-field
flags, 'has_ao' and 'has_wform_ao', and only set them appropriately
based on the board type.

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 | 35 ++++++++++++++++----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c
index ed58ebb..7a6c31e 100644
--- a/drivers/staging/comedi/drivers/das1800.c
+++ b/drivers/staging/comedi/drivers/das1800.c
@@ -204,11 +204,12 @@ static const struct comedi_lrange range_ai_das1802 = {
 struct das1800_board {
 	const char *name;
 	int ai_speed;		/* max conversion period in nanoseconds */
-	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;
+	unsigned int has_ao:1;
+	unsigned int has_wform_ao:1;
 	unsigned int has_8_do_chan:1;
 };
 
@@ -224,9 +225,9 @@ static const struct das1800_board das1800_boards[] = {
 	}, {
 		.name		= "das-1701st-da",
 		.ai_speed	= 6250,
-		.ao_ability	= 1,
 		.ao_n_chan	= 4,
 		.range_ai	= &range_ai_das1801,
+		.has_ao		= 1,
 	}, {
 		.name		= "das-1702st",
 		.ai_speed	= 6250,
@@ -234,9 +235,9 @@ static const struct das1800_board das1800_boards[] = {
 	}, {
 		.name		= "das-1702st-da",
 		.ai_speed	= 6250,
-		.ao_ability	= 1,
 		.ao_n_chan	= 4,
 		.range_ai	= &range_ai_das1802,
+		.has_ao		= 1,
 	}, {
 		.name		= "das-1702hr",
 		.ai_speed	= 20000,
@@ -245,22 +246,22 @@ static const struct das1800_board das1800_boards[] = {
 	}, {
 		.name		= "das-1702hr-da",
 		.ai_speed	= 20000,
-		.ao_ability	= 1,
 		.ao_n_chan	= 2,
 		.range_ai	= &range_ai_das1802,
 		.is_16bit	= 1,
+		.has_ao		= 1,
 	}, {
 		.name		= "das-1701ao",
 		.ai_speed	= 6250,
-		.ao_ability	= 2,
 		.ao_n_chan	= 2,
 		.range_ai	= &range_ai_das1801,
+		.has_wform_ao	= 1,
 	}, {
 		.name		= "das-1702ao",
 		.ai_speed	= 6250,
-		.ao_ability	= 2,
 		.ao_n_chan	= 2,
 		.range_ai	= &range_ai_das1802,
+		.has_wform_ao	= 1,
 	}, {
 		.name		= "das-1801st",
 		.ai_speed	= 3000,
@@ -268,9 +269,9 @@ static const struct das1800_board das1800_boards[] = {
 	}, {
 		.name		= "das-1801st-da",
 		.ai_speed	= 3000,
-		.ao_ability	= 1,
 		.ao_n_chan	= 4,
 		.range_ai	= &range_ai_das1801,
+		.has_ao		= 1,
 	}, {
 		.name		= "das-1802st",
 		.ai_speed	= 3000,
@@ -278,9 +279,9 @@ static const struct das1800_board das1800_boards[] = {
 	}, {
 		.name		= "das-1802st-da",
 		.ai_speed	= 3000,
-		.ao_ability	= 1,
 		.ao_n_chan	= 4,
 		.range_ai	= &range_ai_das1802,
+		.has_ao		= 1,
 	}, {
 		.name		= "das-1802hr",
 		.ai_speed	= 10000,
@@ -289,38 +290,38 @@ static const struct das1800_board das1800_boards[] = {
 	}, {
 		.name		= "das-1802hr-da",
 		.ai_speed	= 10000,
-		.ao_ability	= 1,
 		.ao_n_chan	= 2,
 		.range_ai	= &range_ai_das1802,
 		.is_16bit	= 1,
+		.has_ao		= 1,
 	}, {
 		.name		= "das-1801hc",
 		.ai_speed	= 3000,
-		.ao_ability	= 1,
 		.ao_n_chan	= 2,
 		.range_ai	= &range_ai_das1801,
 		.has_64_ai_chan	= 1,
+		.has_ao		= 1,
 		.has_8_do_chan	= 1,
 	}, {
 		.name		= "das-1802hc",
 		.ai_speed	= 3000,
-		.ao_ability	= 1,
 		.ao_n_chan	= 2,
 		.range_ai	= &range_ai_das1802,
 		.has_64_ai_chan	= 1,
+		.has_ao		= 1,
 		.has_8_do_chan	= 1,
 	}, {
 		.name		= "das-1801ao",
 		.ai_speed	= 3000,
-		.ao_ability	= 2,
 		.ao_n_chan	= 2,
 		.range_ai	= &range_ai_das1801,
+		.has_wform_ao	= 1,
 	}, {
 		.name		= "das-1802ao",
 		.ai_speed	= 3000,
-		.ao_ability	= 2,
 		.ao_n_chan	= 2,
 		.range_ai	= &range_ai_das1802,
+		.has_wform_ao	= 1,
 	},
 };
 
@@ -1202,8 +1203,8 @@ static int das1800_attach(struct comedi_device *dev,
 	dev->board_ptr = board;
 	dev->board_name = board->name;
 
-	/*  if it is an 'ao' board with fancy analog out then we need extra io ports */
-	if (board->ao_ability == 2) {
+	/* waveform 'ao' boards have additional io ports */
+	if (board->has_wform_ao) {
 		unsigned long iobase2 = dev->iobase + IOBASE2;
 
 		ret = __comedi_request_region(dev, iobase2, DAS1800_SIZE);
@@ -1282,7 +1283,7 @@ static int das1800_attach(struct comedi_device *dev,
 
 	/* Analog Output subdevice */
 	s = &dev->subdevices[1];
-	if (board->ao_ability == 1) {
+	if (board->has_ao) {
 		s->type		= COMEDI_SUBD_AO;
 		s->subdev_flags	= SDF_WRITABLE;
 		s->n_chan	= board->ao_n_chan;
@@ -1317,7 +1318,7 @@ static int das1800_attach(struct comedi_device *dev,
 	outb(0, dev->iobase + DAS1800_DIGITAL);
 
 	/*  initialize analog out channels */
-	if (board->ao_ability == 1) {
+	if (board->has_ao) {
 		/*  select 'update' dac channel for baseAddress + 0x0 */
 		outb(DAC(board->ao_n_chan - 1),
 		     dev->iobase + DAS1800_SELECT);
-- 
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