Commit 465e25b5 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: das16: all supported board have analog inputs

All the boards supported by this driver have analog inputs and all
of then use the same function to handle the (*insn_read) for the
subdevice.

Remove the 'ai' member from the boardinfo and always initalize the
analog input subdevice during the board attach.

Tidy up the subdevice init a bit.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b0926a7a
...@@ -338,7 +338,6 @@ struct munge_info { ...@@ -338,7 +338,6 @@ struct munge_info {
struct das16_board { struct das16_board {
const char *name; const char *name;
void *ai;
unsigned int ai_nbits; unsigned int ai_nbits;
unsigned int ai_speed; /* max conversion speed in nanosec */ unsigned int ai_speed; /* max conversion speed in nanosec */
unsigned int ai_pg; unsigned int ai_pg;
...@@ -659,8 +658,10 @@ static void das16_reset(struct comedi_device *dev) ...@@ -659,8 +658,10 @@ static void das16_reset(struct comedi_device *dev)
outb(0, dev->iobase + DAS16_CNTR_CONTROL); outb(0, dev->iobase + DAS16_CNTR_CONTROL);
} }
static int das16_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, static int das16_ai_insn_read(struct comedi_device *dev,
struct comedi_insn *insn, unsigned int *data) struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{ {
const struct das16_board *board = comedi_board(dev); const struct das16_board *board = comedi_board(dev);
struct das16_private_struct *devpriv = dev->private; struct das16_private_struct *devpriv = dev->private;
...@@ -1099,39 +1100,34 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -1099,39 +1100,34 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
if (ret) if (ret)
return ret; return ret;
/* Analog Input subdevice */
s = &dev->subdevices[0]; s = &dev->subdevices[0];
/* ai */ s->type = COMEDI_SUBD_AI;
if (board->ai) { s->subdev_flags = SDF_READABLE;
s->type = COMEDI_SUBD_AI; if (devpriv->ai_singleended) {
s->subdev_flags = SDF_READABLE; s->subdev_flags |= SDF_GROUND;
if (devpriv->ai_singleended) { s->n_chan = 16;
s->n_chan = 16;
s->len_chanlist = 16;
s->subdev_flags |= SDF_GROUND;
} else {
s->n_chan = 8;
s->len_chanlist = 8;
s->subdev_flags |= SDF_DIFF;
}
s->maxdata = (1 << board->ai_nbits) - 1;
if (devpriv->user_ai_range_table) { /* user defined ai range */
s->range_table = devpriv->user_ai_range_table;
} else if (devpriv->ai_unipolar) {
s->range_table = das16_ai_uni_lranges[board->ai_pg];
} else {
s->range_table = das16_ai_bip_lranges[board->ai_pg];
}
s->insn_read = board->ai;
if (devpriv->dma_chan) {
dev->read_subdev = s;
s->subdev_flags |= SDF_CMD_READ;
s->do_cmdtest = das16_cmd_test;
s->do_cmd = das16_cmd_exec;
s->cancel = das16_cancel;
s->munge = das16_ai_munge;
}
} else { } else {
s->type = COMEDI_SUBD_UNUSED; s->subdev_flags |= SDF_DIFF;
s->n_chan = 8;
}
s->len_chanlist = s->n_chan;
s->maxdata = (1 << board->ai_nbits) - 1;
if (devpriv->user_ai_range_table) { /* user defined ai range */
s->range_table = devpriv->user_ai_range_table;
} else if (devpriv->ai_unipolar) {
s->range_table = das16_ai_uni_lranges[board->ai_pg];
} else {
s->range_table = das16_ai_bip_lranges[board->ai_pg];
}
s->insn_read = das16_ai_insn_read;
if (devpriv->dma_chan) {
dev->read_subdev = s;
s->subdev_flags |= SDF_CMD_READ;
s->do_cmdtest = das16_cmd_test;
s->do_cmd = das16_cmd_exec;
s->cancel = das16_cancel;
s->munge = das16_ai_munge;
} }
s = &dev->subdevices[1]; s = &dev->subdevices[1];
...@@ -1232,7 +1228,6 @@ static void das16_detach(struct comedi_device *dev) ...@@ -1232,7 +1228,6 @@ static void das16_detach(struct comedi_device *dev)
static const struct das16_board das16_boards[] = { static const struct das16_board das16_boards[] = {
{ {
.name = "das-16", .name = "das-16",
.ai = das16_ai_rinsn,
.ai_nbits = 12, .ai_nbits = 12,
.ai_speed = 15000, .ai_speed = 15000,
.ai_pg = das16_pg_none, .ai_pg = das16_pg_none,
...@@ -1246,7 +1241,6 @@ static const struct das16_board das16_boards[] = { ...@@ -1246,7 +1241,6 @@ static const struct das16_board das16_boards[] = {
.id = 0x00, .id = 0x00,
}, { }, {
.name = "das-16g", .name = "das-16g",
.ai = das16_ai_rinsn,
.ai_nbits = 12, .ai_nbits = 12,
.ai_speed = 15000, .ai_speed = 15000,
.ai_pg = das16_pg_none, .ai_pg = das16_pg_none,
...@@ -1260,7 +1254,6 @@ static const struct das16_board das16_boards[] = { ...@@ -1260,7 +1254,6 @@ static const struct das16_board das16_boards[] = {
.id = 0x00, .id = 0x00,
}, { }, {
.name = "das-16f", .name = "das-16f",
.ai = das16_ai_rinsn,
.ai_nbits = 12, .ai_nbits = 12,
.ai_speed = 8500, .ai_speed = 8500,
.ai_pg = das16_pg_none, .ai_pg = das16_pg_none,
...@@ -1274,7 +1267,6 @@ static const struct das16_board das16_boards[] = { ...@@ -1274,7 +1267,6 @@ static const struct das16_board das16_boards[] = {
.id = 0x00, .id = 0x00,
}, { }, {
.name = "cio-das16", .name = "cio-das16",
.ai = das16_ai_rinsn,
.ai_nbits = 12, .ai_nbits = 12,
.ai_speed = 20000, .ai_speed = 20000,
.ai_pg = das16_pg_none, .ai_pg = das16_pg_none,
...@@ -1288,7 +1280,6 @@ static const struct das16_board das16_boards[] = { ...@@ -1288,7 +1280,6 @@ static const struct das16_board das16_boards[] = {
.id = 0x80, .id = 0x80,
}, { }, {
.name = "cio-das16/f", .name = "cio-das16/f",
.ai = das16_ai_rinsn,
.ai_nbits = 12, .ai_nbits = 12,
.ai_speed = 10000, .ai_speed = 10000,
.ai_pg = das16_pg_none, .ai_pg = das16_pg_none,
...@@ -1302,7 +1293,6 @@ static const struct das16_board das16_boards[] = { ...@@ -1302,7 +1293,6 @@ static const struct das16_board das16_boards[] = {
.id = 0x80, .id = 0x80,
}, { }, {
.name = "cio-das16/jr", .name = "cio-das16/jr",
.ai = das16_ai_rinsn,
.ai_nbits = 12, .ai_nbits = 12,
.ai_speed = 7692, .ai_speed = 7692,
.ai_pg = das16_pg_16jr, .ai_pg = das16_pg_16jr,
...@@ -1315,7 +1305,6 @@ static const struct das16_board das16_boards[] = { ...@@ -1315,7 +1305,6 @@ static const struct das16_board das16_boards[] = {
.id = 0x00, .id = 0x00,
}, { }, {
.name = "pc104-das16jr", .name = "pc104-das16jr",
.ai = das16_ai_rinsn,
.ai_nbits = 12, .ai_nbits = 12,
.ai_speed = 3300, .ai_speed = 3300,
.ai_pg = das16_pg_16jr, .ai_pg = das16_pg_16jr,
...@@ -1328,7 +1317,6 @@ static const struct das16_board das16_boards[] = { ...@@ -1328,7 +1317,6 @@ static const struct das16_board das16_boards[] = {
.id = 0x00, .id = 0x00,
}, { }, {
.name = "cio-das16jr/16", .name = "cio-das16jr/16",
.ai = das16_ai_rinsn,
.ai_nbits = 16, .ai_nbits = 16,
.ai_speed = 10000, .ai_speed = 10000,
.ai_pg = das16_pg_16jr_16, .ai_pg = das16_pg_16jr_16,
...@@ -1341,7 +1329,6 @@ static const struct das16_board das16_boards[] = { ...@@ -1341,7 +1329,6 @@ static const struct das16_board das16_boards[] = {
.id = 0x00, .id = 0x00,
}, { }, {
.name = "pc104-das16jr/16", .name = "pc104-das16jr/16",
.ai = das16_ai_rinsn,
.ai_nbits = 16, .ai_nbits = 16,
.ai_speed = 10000, .ai_speed = 10000,
.ai_pg = das16_pg_16jr_16, .ai_pg = das16_pg_16jr_16,
...@@ -1354,7 +1341,6 @@ static const struct das16_board das16_boards[] = { ...@@ -1354,7 +1341,6 @@ static const struct das16_board das16_boards[] = {
.id = 0x00, .id = 0x00,
}, { }, {
.name = "das-1201", .name = "das-1201",
.ai = das16_ai_rinsn,
.ai_nbits = 12, .ai_nbits = 12,
.ai_speed = 20000, .ai_speed = 20000,
.ai_pg = das16_pg_none, .ai_pg = das16_pg_none,
...@@ -1367,7 +1353,6 @@ static const struct das16_board das16_boards[] = { ...@@ -1367,7 +1353,6 @@ static const struct das16_board das16_boards[] = {
.id = 0x20, .id = 0x20,
}, { }, {
.name = "das-1202", .name = "das-1202",
.ai = das16_ai_rinsn,
.ai_nbits = 12, .ai_nbits = 12,
.ai_speed = 10000, .ai_speed = 10000,
.ai_pg = das16_pg_none, .ai_pg = das16_pg_none,
...@@ -1380,7 +1365,6 @@ static const struct das16_board das16_boards[] = { ...@@ -1380,7 +1365,6 @@ static const struct das16_board das16_boards[] = {
.id = 0x20, .id = 0x20,
}, { }, {
.name = "das-1401", .name = "das-1401",
.ai = das16_ai_rinsn,
.ai_nbits = 12, .ai_nbits = 12,
.ai_speed = 10000, .ai_speed = 10000,
.ai_pg = das16_pg_1601, .ai_pg = das16_pg_1601,
...@@ -1393,7 +1377,6 @@ static const struct das16_board das16_boards[] = { ...@@ -1393,7 +1377,6 @@ static const struct das16_board das16_boards[] = {
.id = 0xc0, .id = 0xc0,
}, { }, {
.name = "das-1402", .name = "das-1402",
.ai = das16_ai_rinsn,
.ai_nbits = 12, .ai_nbits = 12,
.ai_speed = 10000, .ai_speed = 10000,
.ai_pg = das16_pg_1602, .ai_pg = das16_pg_1602,
...@@ -1406,7 +1389,6 @@ static const struct das16_board das16_boards[] = { ...@@ -1406,7 +1389,6 @@ static const struct das16_board das16_boards[] = {
.id = 0xc0, .id = 0xc0,
}, { }, {
.name = "das-1601", .name = "das-1601",
.ai = das16_ai_rinsn,
.ai_nbits = 12, .ai_nbits = 12,
.ai_speed = 10000, .ai_speed = 10000,
.ai_pg = das16_pg_1601, .ai_pg = das16_pg_1601,
...@@ -1420,7 +1402,6 @@ static const struct das16_board das16_boards[] = { ...@@ -1420,7 +1402,6 @@ static const struct das16_board das16_boards[] = {
.id = 0xc0, .id = 0xc0,
}, { }, {
.name = "das-1602", .name = "das-1602",
.ai = das16_ai_rinsn,
.ai_nbits = 12, .ai_nbits = 12,
.ai_speed = 10000, .ai_speed = 10000,
.ai_pg = das16_pg_1602, .ai_pg = das16_pg_1602,
...@@ -1434,7 +1415,6 @@ static const struct das16_board das16_boards[] = { ...@@ -1434,7 +1415,6 @@ static const struct das16_board das16_boards[] = {
.id = 0xc0, .id = 0xc0,
}, { }, {
.name = "cio-das1401/12", .name = "cio-das1401/12",
.ai = das16_ai_rinsn,
.ai_nbits = 12, .ai_nbits = 12,
.ai_speed = 6250, .ai_speed = 6250,
.ai_pg = das16_pg_1601, .ai_pg = das16_pg_1601,
...@@ -1447,7 +1427,6 @@ static const struct das16_board das16_boards[] = { ...@@ -1447,7 +1427,6 @@ static const struct das16_board das16_boards[] = {
.id = 0xc0, .id = 0xc0,
}, { }, {
.name = "cio-das1402/12", .name = "cio-das1402/12",
.ai = das16_ai_rinsn,
.ai_nbits = 12, .ai_nbits = 12,
.ai_speed = 6250, .ai_speed = 6250,
.ai_pg = das16_pg_1602, .ai_pg = das16_pg_1602,
...@@ -1460,7 +1439,6 @@ static const struct das16_board das16_boards[] = { ...@@ -1460,7 +1439,6 @@ static const struct das16_board das16_boards[] = {
.id = 0xc0, .id = 0xc0,
}, { }, {
.name = "cio-das1402/16", .name = "cio-das1402/16",
.ai = das16_ai_rinsn,
.ai_nbits = 16, .ai_nbits = 16,
.ai_speed = 10000, .ai_speed = 10000,
.ai_pg = das16_pg_1602, .ai_pg = das16_pg_1602,
...@@ -1473,7 +1451,6 @@ static const struct das16_board das16_boards[] = { ...@@ -1473,7 +1451,6 @@ static const struct das16_board das16_boards[] = {
.id = 0xc0, .id = 0xc0,
}, { }, {
.name = "cio-das1601/12", .name = "cio-das1601/12",
.ai = das16_ai_rinsn,
.ai_nbits = 12, .ai_nbits = 12,
.ai_speed = 6250, .ai_speed = 6250,
.ai_pg = das16_pg_1601, .ai_pg = das16_pg_1601,
...@@ -1487,7 +1464,6 @@ static const struct das16_board das16_boards[] = { ...@@ -1487,7 +1464,6 @@ static const struct das16_board das16_boards[] = {
.id = 0xc0, .id = 0xc0,
}, { }, {
.name = "cio-das1602/12", .name = "cio-das1602/12",
.ai = das16_ai_rinsn,
.ai_nbits = 12, .ai_nbits = 12,
.ai_speed = 10000, .ai_speed = 10000,
.ai_pg = das16_pg_1602, .ai_pg = das16_pg_1602,
...@@ -1501,7 +1477,6 @@ static const struct das16_board das16_boards[] = { ...@@ -1501,7 +1477,6 @@ static const struct das16_board das16_boards[] = {
.id = 0xc0, .id = 0xc0,
}, { }, {
.name = "cio-das1602/16", .name = "cio-das1602/16",
.ai = das16_ai_rinsn,
.ai_nbits = 16, .ai_nbits = 16,
.ai_speed = 10000, .ai_speed = 10000,
.ai_pg = das16_pg_1602, .ai_pg = das16_pg_1602,
...@@ -1515,7 +1490,6 @@ static const struct das16_board das16_boards[] = { ...@@ -1515,7 +1490,6 @@ static const struct das16_board das16_boards[] = {
.id = 0xc0, .id = 0xc0,
}, { }, {
.name = "cio-das16/330", .name = "cio-das16/330",
.ai = das16_ai_rinsn,
.ai_nbits = 12, .ai_nbits = 12,
.ai_speed = 3030, .ai_speed = 3030,
.ai_pg = das16_pg_16jr, .ai_pg = das16_pg_16jr,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment