Commit 344a15c1 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: adl_pci9118: refactor 'rangelist_ai' in boardinfo

The boards supported by this driver either have "normal" or "high gain"
analog input ranges.

For aesthetics, replace the 'rangelist_ai' member in the boardinfo with
a bit-field flag 'is_hg' to indicate the "high gain" range is used.
Refactor the subdevice init to use the flag to set the correct range_table.
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 84f3e3a8
...@@ -197,7 +197,7 @@ ...@@ -197,7 +197,7 @@
#define PCI9118_HALF_FIFO_SZ (1024 / 2) #define PCI9118_HALF_FIFO_SZ (1024 / 2)
static const struct comedi_lrange range_pci9118dg_hr = { static const struct comedi_lrange pci9118_ai_range = {
8, { 8, {
BIP_RANGE(5), BIP_RANGE(5),
BIP_RANGE(2.5), BIP_RANGE(2.5),
...@@ -210,7 +210,7 @@ static const struct comedi_lrange range_pci9118dg_hr = { ...@@ -210,7 +210,7 @@ static const struct comedi_lrange range_pci9118dg_hr = {
} }
}; };
static const struct comedi_lrange range_pci9118hg = { static const struct comedi_lrange pci9118hg_ai_range = {
8, { 8, {
BIP_RANGE(5), BIP_RANGE(5),
BIP_RANGE(0.5), BIP_RANGE(0.5),
...@@ -232,7 +232,7 @@ struct boardtype { ...@@ -232,7 +232,7 @@ struct boardtype {
const char *name; /* board name */ const char *name; /* board name */
int device_id; /* PCI device ID of card */ int device_id; /* PCI device ID of card */
int ai_maxdata; /* resolution of A/D */ int ai_maxdata; /* resolution of A/D */
const struct comedi_lrange *rangelist_ai; /* rangelist for A/D */ unsigned int is_hg:1;
}; };
static const struct boardtype boardtypes[] = { static const struct boardtype boardtypes[] = {
...@@ -240,17 +240,15 @@ static const struct boardtype boardtypes[] = { ...@@ -240,17 +240,15 @@ static const struct boardtype boardtypes[] = {
.name = "pci9118dg", .name = "pci9118dg",
.device_id = 0x80d9, .device_id = 0x80d9,
.ai_maxdata = 0x0fff, .ai_maxdata = 0x0fff,
.rangelist_ai = &range_pci9118dg_hr,
}, { }, {
.name = "pci9118hg", .name = "pci9118hg",
.device_id = 0x80d9, .device_id = 0x80d9,
.ai_maxdata = 0x0fff, .ai_maxdata = 0x0fff,
.rangelist_ai = &range_pci9118hg, .is_hg = 1,
}, { }, {
.name = "pci9118hr", .name = "pci9118hr",
.device_id = 0x80d9, .device_id = 0x80d9,
.ai_maxdata = 0xffff, .ai_maxdata = 0xffff,
.rangelist_ai = &range_pci9118dg_hr,
}, },
}; };
...@@ -1874,7 +1872,8 @@ static int pci9118_common_attach(struct comedi_device *dev, int disable_irq, ...@@ -1874,7 +1872,8 @@ static int pci9118_common_attach(struct comedi_device *dev, int disable_irq,
s->n_chan = 16; s->n_chan = 16;
s->maxdata = this_board->ai_maxdata; s->maxdata = this_board->ai_maxdata;
s->range_table = this_board->rangelist_ai; s->range_table = this_board->is_hg ? &pci9118hg_ai_range
: &pci9118_ai_range;
s->insn_read = pci9118_insn_read_ai; s->insn_read = pci9118_insn_read_ai;
if (dev->irq) { if (dev->irq) {
dev->read_subdev = s; dev->read_subdev = s;
......
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