The boards supported by this driver have analog inputs with gains of 1, 10, 50, and 250 ("01" type) or 1, 2, 4, and 8 ("02" type). Replace the 'range_ai' member of the boardinfo with a bit-field flag, 'das1801_range' and only set it for the "01" type boards. Remove the unnecessary initialization for the "02" type boards. For aesthetics, rename the comedi_lrange arrays and document the gain. 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 | 67 +++++++++++++------------------- 1 file changed, 28 insertions(+), 39 deletions(-) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 88ba051..44a5ac1 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -174,39 +174,38 @@ enum { das1802hr, das1802hr_da, das1801hc, das1802hc, das1801ao, das1802ao }; -/* analog input ranges */ -static const struct comedi_lrange range_ai_das1801 = { +static const struct comedi_lrange das1801_ai_range = { 8, { - BIP_RANGE(5), - BIP_RANGE(1), - BIP_RANGE(0.1), - BIP_RANGE(0.02), - UNI_RANGE(5), - UNI_RANGE(1), - UNI_RANGE(0.1), - UNI_RANGE(0.02) + BIP_RANGE(5), /* bipolar gain = 1 */ + BIP_RANGE(1), /* bipolar gain = 10 */ + BIP_RANGE(0.1), /* bipolar gain = 50 */ + BIP_RANGE(0.02), /* bipolar gain = 250 */ + UNI_RANGE(5), /* unipolar gain = 1 */ + UNI_RANGE(1), /* unipolar gain = 10 */ + UNI_RANGE(0.1), /* unipolar gain = 50 */ + UNI_RANGE(0.02) /* unipolar gain = 250 */ } }; -static const struct comedi_lrange range_ai_das1802 = { +static const struct comedi_lrange das1802_ai_range = { 8, { - BIP_RANGE(10), - BIP_RANGE(5), - BIP_RANGE(2.5), - BIP_RANGE(1.25), - UNI_RANGE(10), - UNI_RANGE(5), - UNI_RANGE(2.5), - UNI_RANGE(1.25) + BIP_RANGE(10), /* bipolar gain = 1 */ + BIP_RANGE(5), /* bipolar gain = 2 */ + BIP_RANGE(2.5), /* bipolar gain = 4 */ + BIP_RANGE(1.25), /* bipolar gain = 8 */ + UNI_RANGE(10), /* unipolar gain = 1 */ + UNI_RANGE(5), /* unipolar gain = 2 */ + UNI_RANGE(2.5), /* unipolar gain = 4 */ + UNI_RANGE(1.25) /* unipolar gain = 8 */ } }; struct das1800_board { const char *name; int ai_speed; /* max conversion period in nanoseconds */ - const struct comedi_lrange *range_ai; /* available input ranges */ unsigned int is_16bit:1; unsigned int has_64_ai_chan:1; + unsigned int das1801_range:1; unsigned int has_ao:1; unsigned int has_wform_ao:1; unsigned int has_4_ao_chan:1; @@ -221,98 +220,87 @@ static const struct das1800_board das1800_boards[] = { { .name = "das-1701st", .ai_speed = 6250, - .range_ai = &range_ai_das1801, + .das1801_range = 1, }, { .name = "das-1701st-da", .ai_speed = 6250, - .range_ai = &range_ai_das1801, + .das1801_range = 1, .has_ao = 1, .has_4_ao_chan = 1, }, { .name = "das-1702st", .ai_speed = 6250, - .range_ai = &range_ai_das1802, }, { .name = "das-1702st-da", .ai_speed = 6250, - .range_ai = &range_ai_das1802, .has_ao = 1, .has_4_ao_chan = 1, }, { .name = "das-1702hr", .ai_speed = 20000, - .range_ai = &range_ai_das1802, .is_16bit = 1, }, { .name = "das-1702hr-da", .ai_speed = 20000, - .range_ai = &range_ai_das1802, .is_16bit = 1, .has_ao = 1, }, { .name = "das-1701ao", .ai_speed = 6250, - .range_ai = &range_ai_das1801, + .das1801_range = 1, .has_wform_ao = 1, }, { .name = "das-1702ao", .ai_speed = 6250, - .range_ai = &range_ai_das1802, .has_wform_ao = 1, }, { .name = "das-1801st", .ai_speed = 3000, - .range_ai = &range_ai_das1801, + .das1801_range = 1, }, { .name = "das-1801st-da", .ai_speed = 3000, - .range_ai = &range_ai_das1801, + .das1801_range = 1, .has_ao = 1, .has_4_ao_chan = 1, }, { .name = "das-1802st", .ai_speed = 3000, - .range_ai = &range_ai_das1802, }, { .name = "das-1802st-da", .ai_speed = 3000, - .range_ai = &range_ai_das1802, .has_ao = 1, .has_4_ao_chan = 1, }, { .name = "das-1802hr", .ai_speed = 10000, - .range_ai = &range_ai_das1802, .is_16bit = 1, }, { .name = "das-1802hr-da", .ai_speed = 10000, - .range_ai = &range_ai_das1802, .is_16bit = 1, .has_ao = 1, }, { .name = "das-1801hc", .ai_speed = 3000, - .range_ai = &range_ai_das1801, .has_64_ai_chan = 1, + .das1801_range = 1, .has_ao = 1, .has_8_do_chan = 1, }, { .name = "das-1802hc", .ai_speed = 3000, - .range_ai = &range_ai_das1802, .has_64_ai_chan = 1, .has_ao = 1, .has_8_do_chan = 1, }, { .name = "das-1801ao", .ai_speed = 3000, - .range_ai = &range_ai_das1801, + .das1801_range = 1, .has_wform_ao = 1, }, { .name = "das-1802ao", .ai_speed = 3000, - .range_ai = &range_ai_das1802, .has_wform_ao = 1, }, }; @@ -1261,7 +1249,8 @@ static int das1800_attach(struct comedi_device *dev, s->subdev_flags |= SDF_COMMON; s->n_chan = (board->has_64_ai_chan) ? 64 : 16; s->maxdata = (board->is_16bit) ? 0xffff : 0x0fff; - s->range_table = board->range_ai; + s->range_table = (board->das1801_range) ? &das1801_ai_range + : &das1802_ai_range; s->insn_read = das1800_ai_insn_read; if (dev->irq) { dev->read_subdev = s; -- 2.6.3 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel