The "hc" type boards have 64 analog input channels with a 64 entry queue.
All the others have 16 channels and a 256 entry queue.

Currently the boardinfo 'qram_len' is used to initialize the subdevice
'n_chan' and 'len_chanlist'. This works for the 64 channel boards but
sets the 'n_chan' wrong for the 16 channel boards.

Replace the 'qram_len' member of the boardinfo with a bit-field flag,
'has_64_ai_chan' and use that to properly initialize the subdevice.
Remove the unnecessary initialization for the boards that have 16
channels.

Signed-off-by: H Hartley Sweeten <hswee...@visionengravers.com>
Cc: Ian Abbott <abbo...@mev.co.uk>
Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org>
---
 drivers/staging/comedi/drivers/das1800.c | 26 +++++---------------------
 1 file changed, 5 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/comedi/drivers/das1800.c 
b/drivers/staging/comedi/drivers/das1800.c
index b93a8e7..f80a579 100644
--- a/drivers/staging/comedi/drivers/das1800.c
+++ b/drivers/staging/comedi/drivers/das1800.c
@@ -205,12 +205,12 @@ struct das1800_board {
        const char *name;
        int ai_speed;           /* max conversion period in nanoseconds */
        int resolution;         /* bits of ai resolution */
-       int qram_len;           /* length of card's channel / gain queue */
        int common;             /* supports AREF_COMMON flag */
        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 has_64_ai_chan:1;
 };
 
 /* Warning: the maximum conversion speeds listed below are
@@ -222,7 +222,6 @@ static const struct das1800_board das1800_boards[] = {
         .name = "das-1701st",
         .ai_speed = 6250,
         .resolution = 12,
-        .qram_len = 256,
         .common = 1,
         .do_n_chan = 4,
         .ao_ability = 0,
@@ -233,7 +232,6 @@ static const struct das1800_board das1800_boards[] = {
         .name = "das-1701st-da",
         .ai_speed = 6250,
         .resolution = 12,
-        .qram_len = 256,
         .common = 1,
         .do_n_chan = 4,
         .ao_ability = 1,
@@ -244,7 +242,6 @@ static const struct das1800_board das1800_boards[] = {
         .name = "das-1702st",
         .ai_speed = 6250,
         .resolution = 12,
-        .qram_len = 256,
         .common = 1,
         .do_n_chan = 4,
         .ao_ability = 0,
@@ -255,7 +252,6 @@ static const struct das1800_board das1800_boards[] = {
         .name = "das-1702st-da",
         .ai_speed = 6250,
         .resolution = 12,
-        .qram_len = 256,
         .common = 1,
         .do_n_chan = 4,
         .ao_ability = 1,
@@ -266,7 +262,6 @@ static const struct das1800_board das1800_boards[] = {
         .name = "das-1702hr",
         .ai_speed = 20000,
         .resolution = 16,
-        .qram_len = 256,
         .common = 1,
         .do_n_chan = 4,
         .ao_ability = 0,
@@ -277,7 +272,6 @@ static const struct das1800_board das1800_boards[] = {
         .name = "das-1702hr-da",
         .ai_speed = 20000,
         .resolution = 16,
-        .qram_len = 256,
         .common = 1,
         .do_n_chan = 4,
         .ao_ability = 1,
@@ -288,7 +282,6 @@ static const struct das1800_board das1800_boards[] = {
         .name = "das-1701ao",
         .ai_speed = 6250,
         .resolution = 12,
-        .qram_len = 256,
         .common = 1,
         .do_n_chan = 4,
         .ao_ability = 2,
@@ -299,7 +292,6 @@ static const struct das1800_board das1800_boards[] = {
         .name = "das-1702ao",
         .ai_speed = 6250,
         .resolution = 12,
-        .qram_len = 256,
         .common = 1,
         .do_n_chan = 4,
         .ao_ability = 2,
@@ -310,7 +302,6 @@ static const struct das1800_board das1800_boards[] = {
         .name = "das-1801st",
         .ai_speed = 3000,
         .resolution = 12,
-        .qram_len = 256,
         .common = 1,
         .do_n_chan = 4,
         .ao_ability = 0,
@@ -321,7 +312,6 @@ static const struct das1800_board das1800_boards[] = {
         .name = "das-1801st-da",
         .ai_speed = 3000,
         .resolution = 12,
-        .qram_len = 256,
         .common = 1,
         .do_n_chan = 4,
         .ao_ability = 0,
@@ -332,7 +322,6 @@ static const struct das1800_board das1800_boards[] = {
         .name = "das-1802st",
         .ai_speed = 3000,
         .resolution = 12,
-        .qram_len = 256,
         .common = 1,
         .do_n_chan = 4,
         .ao_ability = 0,
@@ -343,7 +332,6 @@ static const struct das1800_board das1800_boards[] = {
         .name = "das-1802st-da",
         .ai_speed = 3000,
         .resolution = 12,
-        .qram_len = 256,
         .common = 1,
         .do_n_chan = 4,
         .ao_ability = 1,
@@ -354,7 +342,6 @@ static const struct das1800_board das1800_boards[] = {
         .name = "das-1802hr",
         .ai_speed = 10000,
         .resolution = 16,
-        .qram_len = 256,
         .common = 1,
         .do_n_chan = 4,
         .ao_ability = 0,
@@ -365,7 +352,6 @@ static const struct das1800_board das1800_boards[] = {
         .name = "das-1802hr-da",
         .ai_speed = 10000,
         .resolution = 16,
-        .qram_len = 256,
         .common = 1,
         .do_n_chan = 4,
         .ao_ability = 1,
@@ -376,29 +362,28 @@ static const struct das1800_board das1800_boards[] = {
         .name = "das-1801hc",
         .ai_speed = 3000,
         .resolution = 12,
-        .qram_len = 64,
         .common = 0,
         .do_n_chan = 8,
         .ao_ability = 1,
         .ao_n_chan = 2,
         .range_ai = &range_ai_das1801,
+        .has_64_ai_chan = 1,
         },
        {
         .name = "das-1802hc",
         .ai_speed = 3000,
         .resolution = 12,
-        .qram_len = 64,
         .common = 0,
         .do_n_chan = 8,
         .ao_ability = 1,
         .ao_n_chan = 2,
         .range_ai = &range_ai_das1802,
+        .has_64_ai_chan = 1,
         },
        {
         .name = "das-1801ao",
         .ai_speed = 3000,
         .resolution = 12,
-        .qram_len = 256,
         .common = 1,
         .do_n_chan = 4,
         .ao_ability = 2,
@@ -409,7 +394,6 @@ static const struct das1800_board das1800_boards[] = {
         .name = "das-1802ao",
         .ai_speed = 3000,
         .resolution = 12,
-        .qram_len = 256,
         .common = 1,
         .do_n_chan = 4,
         .ao_ability = 2,
@@ -1355,14 +1339,14 @@ static int das1800_attach(struct comedi_device *dev,
        s->subdev_flags = SDF_READABLE | SDF_DIFF | SDF_GROUND;
        if (board->common)
                s->subdev_flags |= SDF_COMMON;
-       s->n_chan = board->qram_len;
+       s->n_chan = (board->has_64_ai_chan) ? 64 : 16;
        s->maxdata = (1 << board->resolution) - 1;
        s->range_table = board->range_ai;
        s->insn_read = das1800_ai_rinsn;
        if (dev->irq) {
                dev->read_subdev = s;
                s->subdev_flags |= SDF_CMD_READ;
-               s->len_chanlist = s->n_chan;
+               s->len_chanlist = (board->has_64_ai_chan) ? 64 : 256;
                s->do_cmd = das1800_ai_do_cmd;
                s->do_cmdtest = das1800_ai_do_cmdtest;
                s->poll = das1800_ai_poll;
-- 
2.6.3

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

Reply via email to