staging: comedi: dt3000: refactor 'adbits' boardinfo
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Thu, 8 Oct 2015 17:48:23 +0000 (10:48 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 13 Oct 2015 05:59:26 +0000 (22:59 -0700)
All the board supported by this driver have analog inputs. The input
resolution is either 12-bit or 16-bit.

Replace the 'adbits' member of the boardinfo with a bit-field flag
'ai_is_16bits' and just set if for the 16-bit boards.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/dt3000.c

index fdae78d1690dec82e8b45530b5f54e49de51044f..8d6d34487f5679745e7b5befa2ea3b2eb06da7f8 100644 (file)
@@ -168,18 +168,17 @@ enum dt3k_boardid {
 struct dt3k_boardtype {
        const char *name;
        int adchan;
-       int adbits;
        int ai_speed;
        const struct comedi_lrange *adrange;
        int dachan;
        int dabits;
+       unsigned int ai_is_16bit:1;
 };
 
 static const struct dt3k_boardtype dt3k_boardtypes[] = {
        [BOARD_DT3001] = {
                .name           = "dt3001",
                .adchan         = 16,
-               .adbits         = 12,
                .adrange        = &range_dt3000_ai,
                .ai_speed       = 3000,
                .dachan         = 2,
@@ -188,7 +187,6 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
        [BOARD_DT3001_PGL] = {
                .name           = "dt3001-pgl",
                .adchan         = 16,
-               .adbits         = 12,
                .adrange        = &range_dt3000_ai_pgl,
                .ai_speed       = 3000,
                .dachan         = 2,
@@ -197,14 +195,12 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
        [BOARD_DT3002] = {
                .name           = "dt3002",
                .adchan         = 32,
-               .adbits         = 12,
                .adrange        = &range_dt3000_ai,
                .ai_speed       = 3000,
        },
        [BOARD_DT3003] = {
                .name           = "dt3003",
                .adchan         = 64,
-               .adbits         = 12,
                .adrange        = &range_dt3000_ai,
                .ai_speed       = 3000,
                .dachan         = 2,
@@ -213,7 +209,6 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
        [BOARD_DT3003_PGL] = {
                .name           = "dt3003-pgl",
                .adchan         = 64,
-               .adbits         = 12,
                .adrange        = &range_dt3000_ai_pgl,
                .ai_speed       = 3000,
                .dachan         = 2,
@@ -222,20 +217,20 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {
        [BOARD_DT3004] = {
                .name           = "dt3004",
                .adchan         = 16,
-               .adbits         = 16,
                .adrange        = &range_dt3000_ai,
                .ai_speed       = 10000,
                .dachan         = 2,
                .dabits         = 12,
+               .ai_is_16bit    = 1,
        },
        [BOARD_DT3005] = {
                .name           = "dt3005",     /* a.k.a. 3004-200 */
                .adchan         = 16,
-               .adbits         = 16,
                .adrange        = &range_dt3000_ai,
                .ai_speed       = 5000,
                .dachan         = 2,
                .dabits         = 12,
+               .ai_is_16bit    = 1,
        },
 };
 
@@ -675,7 +670,7 @@ static int dt3000_auto_attach(struct comedi_device *dev,
        s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF;
        s->n_chan       = board->adchan;
        s->insn_read    = dt3k_ai_insn;
-       s->maxdata      = (1 << board->adbits) - 1;
+       s->maxdata      = board->ai_is_16bit ? 0xffff : 0x0fff;
        s->range_table  = &range_dt3000_ai;     /* XXX */
        if (dev->irq) {
                dev->read_subdev = s;