]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
staging: comedi: das16: all supported board have digital inputs
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 29 Jul 2013 20:54:09 +0000 (13:54 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Aug 2013 00:37:45 +0000 (17:37 -0700)
All the boards supported by this driver have digital inputs and all
of then use the same function to handle the (*insn_bits) for the
subdevice.

Remove the 'di' member from the boardinfo and always initialize the
digital input subdevice during the board attach.

Tidy up the subdevice init a bit as well as the (*insn_bits) function.
The (*insn_bits) function does not need to clear data[0].

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/das16.c

index 11e5787dd27ef875f5f36f54e27c327e3f9f9b18..3528c8257a5cf1c41a54bc103c026a02add483a6 100644 (file)
@@ -343,7 +343,6 @@ struct das16_board {
        unsigned int ai_pg;
        void *ao;
        unsigned int ao_nbits;
-       void *di;
        void *do_;
 
        unsigned int i8255_offset;
@@ -712,14 +711,12 @@ static int das16_ai_insn_read(struct comedi_device *dev,
        return n;
 }
 
-static int das16_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
-                         struct comedi_insn *insn, unsigned int *data)
+static int das16_di_insn_bits(struct comedi_device *dev,
+                             struct comedi_subdevice *s,
+                             struct comedi_insn *insn,
+                             unsigned int *data)
 {
-       unsigned int bits;
-
-       bits = inb(dev->iobase + DAS16_DIO) & 0xf;
-       data[1] = bits;
-       data[0] = 0;
+       data[1] = inb(dev->iobase + DAS16_DIO) & 0xf;
 
        return insn->n;
 }
@@ -1149,18 +1146,14 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
                s->type = COMEDI_SUBD_UNUSED;
        }
 
+       /* Digital Input subdevice */
        s = &dev->subdevices[2];
-       /* di */
-       if (board->di) {
-               s->type = COMEDI_SUBD_DI;
-               s->subdev_flags = SDF_READABLE;
-               s->n_chan = 4;
-               s->maxdata = 1;
-               s->range_table = &range_digital;
-               s->insn_bits = board->di;
-       } else {
-               s->type = COMEDI_SUBD_UNUSED;
-       }
+       s->type         = COMEDI_SUBD_DI;
+       s->subdev_flags = SDF_READABLE;
+       s->n_chan       = 4;
+       s->maxdata      = 1;
+       s->range_table  = &range_digital;
+       s->insn_bits    = das16_di_insn_bits;
 
        s = &dev->subdevices[3];
        /* do */
@@ -1234,7 +1227,6 @@ static const struct das16_board das16_boards[] = {
                .ai_pg          = das16_pg_none,
                .ao             = das16_ao_winsn,
                .ao_nbits       = 12,
-               .di             = das16_di_rbits,
                .do_            = das16_do_wbits,
                .i8255_offset   = 0x10,
                .i8254_offset   = 0x0c,
@@ -1247,7 +1239,6 @@ static const struct das16_board das16_boards[] = {
                .ai_pg          = das16_pg_none,
                .ao             = das16_ao_winsn,
                .ao_nbits       = 12,
-               .di             = das16_di_rbits,
                .do_            = das16_do_wbits,
                .i8255_offset   = 0x10,
                .i8254_offset   = 0x0c,
@@ -1260,7 +1251,6 @@ static const struct das16_board das16_boards[] = {
                .ai_pg          = das16_pg_none,
                .ao             = das16_ao_winsn,
                .ao_nbits       = 12,
-               .di             = das16_di_rbits,
                .do_            = das16_do_wbits,
                .i8255_offset   = 0x10,
                .i8254_offset   = 0x0c,
@@ -1273,7 +1263,6 @@ static const struct das16_board das16_boards[] = {
                .ai_pg          = das16_pg_none,
                .ao             = das16_ao_winsn,
                .ao_nbits       = 12,
-               .di             = das16_di_rbits,
                .do_            = das16_do_wbits,
                .i8255_offset   = 0x10,
                .i8254_offset   = 0x0c,
@@ -1286,7 +1275,6 @@ static const struct das16_board das16_boards[] = {
                .ai_pg          = das16_pg_none,
                .ao             = das16_ao_winsn,
                .ao_nbits       = 12,
-               .di             = das16_di_rbits,
                .do_            = das16_do_wbits,
                .i8255_offset   = 0x10,
                .i8254_offset   = 0x0c,
@@ -1298,7 +1286,6 @@ static const struct das16_board das16_boards[] = {
                .ai_speed       = 7692,
                .ai_pg          = das16_pg_16jr,
                .ao             = NULL,
-               .di             = das16_di_rbits,
                .do_            = das16_do_wbits,
                .i8255_offset   = 0,
                .i8254_offset   = 0x0c,
@@ -1310,7 +1297,6 @@ static const struct das16_board das16_boards[] = {
                .ai_speed       = 3300,
                .ai_pg          = das16_pg_16jr,
                .ao             = NULL,
-               .di             = das16_di_rbits,
                .do_            = das16_do_wbits,
                .i8255_offset   = 0,
                .i8254_offset   = 0x0c,
@@ -1322,7 +1308,6 @@ static const struct das16_board das16_boards[] = {
                .ai_speed       = 10000,
                .ai_pg          = das16_pg_16jr_16,
                .ao             = NULL,
-               .di             = das16_di_rbits,
                .do_            = das16_do_wbits,
                .i8255_offset   = 0,
                .i8254_offset   = 0x0c,
@@ -1334,7 +1319,6 @@ static const struct das16_board das16_boards[] = {
                .ai_speed       = 10000,
                .ai_pg          = das16_pg_16jr_16,
                .ao             = NULL,
-               .di             = das16_di_rbits,
                .do_            = das16_do_wbits,
                .i8255_offset   = 0,
                .i8254_offset   = 0x0c,
@@ -1346,7 +1330,6 @@ static const struct das16_board das16_boards[] = {
                .ai_speed       = 20000,
                .ai_pg          = das16_pg_none,
                .ao             = NULL,
-               .di             = das16_di_rbits,
                .do_            = das16_do_wbits,
                .i8255_offset   = 0x400,
                .i8254_offset   = 0x0c,
@@ -1358,7 +1341,6 @@ static const struct das16_board das16_boards[] = {
                .ai_speed       = 10000,
                .ai_pg          = das16_pg_none,
                .ao             = NULL,
-               .di             = das16_di_rbits,
                .do_            = das16_do_wbits,
                .i8255_offset   = 0x400,
                .i8254_offset   = 0x0c,
@@ -1370,7 +1352,6 @@ static const struct das16_board das16_boards[] = {
                .ai_speed       = 10000,
                .ai_pg          = das16_pg_1601,
                .ao             = NULL,
-               .di             = das16_di_rbits,
                .do_            = das16_do_wbits,
                .i8255_offset   = 0x0,
                .i8254_offset   = 0x0c,
@@ -1382,7 +1363,6 @@ static const struct das16_board das16_boards[] = {
                .ai_speed       = 10000,
                .ai_pg          = das16_pg_1602,
                .ao             = NULL,
-               .di             = das16_di_rbits,
                .do_            = das16_do_wbits,
                .i8255_offset   = 0x0,
                .i8254_offset   = 0x0c,
@@ -1395,7 +1375,6 @@ static const struct das16_board das16_boards[] = {
                .ai_pg          = das16_pg_1601,
                .ao             = das16_ao_winsn,
                .ao_nbits       = 12,
-               .di             = das16_di_rbits,
                .do_            = das16_do_wbits,
                .i8255_offset   = 0x400,
                .i8254_offset   = 0x0c,
@@ -1408,7 +1387,6 @@ static const struct das16_board das16_boards[] = {
                .ai_pg          = das16_pg_1602,
                .ao             = das16_ao_winsn,
                .ao_nbits       = 12,
-               .di             = das16_di_rbits,
                .do_            = das16_do_wbits,
                .i8255_offset   = 0x400,
                .i8254_offset   = 0x0c,
@@ -1420,7 +1398,6 @@ static const struct das16_board das16_boards[] = {
                .ai_speed       = 6250,
                .ai_pg          = das16_pg_1601,
                .ao             = NULL,
-               .di             = das16_di_rbits,
                .do_            = das16_do_wbits,
                .i8255_offset   = 0,
                .i8254_offset   = 0x0c,
@@ -1432,7 +1409,6 @@ static const struct das16_board das16_boards[] = {
                .ai_speed       = 6250,
                .ai_pg          = das16_pg_1602,
                .ao             = NULL,
-               .di             = das16_di_rbits,
                .do_            = das16_do_wbits,
                .i8255_offset   = 0,
                .i8254_offset   = 0x0c,
@@ -1444,7 +1420,6 @@ static const struct das16_board das16_boards[] = {
                .ai_speed       = 10000,
                .ai_pg          = das16_pg_1602,
                .ao             = NULL,
-               .di             = das16_di_rbits,
                .do_            = das16_do_wbits,
                .i8255_offset   = 0,
                .i8254_offset   = 0x0c,
@@ -1457,7 +1432,6 @@ static const struct das16_board das16_boards[] = {
                .ai_pg          = das16_pg_1601,
                .ao             = das16_ao_winsn,
                .ao_nbits       = 12,
-               .di             = das16_di_rbits,
                .do_            = das16_do_wbits,
                .i8255_offset   = 0x400,
                .i8254_offset   = 0x0c,
@@ -1470,7 +1444,6 @@ static const struct das16_board das16_boards[] = {
                .ai_pg          = das16_pg_1602,
                .ao             = das16_ao_winsn,
                .ao_nbits       = 12,
-               .di             = das16_di_rbits,
                .do_            = das16_do_wbits,
                .i8255_offset   = 0x400,
                .i8254_offset   = 0x0c,
@@ -1483,7 +1456,6 @@ static const struct das16_board das16_boards[] = {
                .ai_pg          = das16_pg_1602,
                .ao             = das16_ao_winsn,
                .ao_nbits       = 12,
-               .di             = das16_di_rbits,
                .do_            = das16_do_wbits,
                .i8255_offset   = 0x400,
                .i8254_offset   = 0x0c,
@@ -1495,7 +1467,6 @@ static const struct das16_board das16_boards[] = {
                .ai_speed       = 3030,
                .ai_pg          = das16_pg_16jr,
                .ao             = NULL,
-               .di             = das16_di_rbits,
                .do_            = das16_do_wbits,
                .i8255_offset   = 0,
                .i8254_offset   = 0x0c,