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

staging: comedi: ni_stc.h: remove 'ao_unipolar' flag from ni_board_struct

This member of the boardinfo for the NI MIO drivers is used to indicate if
the ranges for the analog output subdevice (ao_range_table in the boardinfo)
includes any unipolar ranges. If it's not set, the ao_range_table only has
bipolar ranges.

The 'ao_unipolar' flag is checked when munging the ao data values from the
user so that the values for bipolar ranges are converted to 2's complement
values before they are written to the hardware.

The flag is also used when programming the analog output configuration on
non-M series boards for bipolar/unipolar and external reference operation.

Simplify the driver a bit by removing this boardinfo flag and just using
the comedi_range_is_bipolar() and comedi_range_is_external() helpers to
check the range directly.
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 a8b677cb
...@@ -116,7 +116,6 @@ static const struct ni_board_struct ni_boards[] = { ...@@ -116,7 +116,6 @@ static const struct ni_board_struct ni_boards[] = {
.aobits = 12, .aobits = 12,
.ao_fifo_depth = 2048, .ao_fifo_depth = 2048,
.ao_range_table = &range_ni_E_ao_ext, .ao_range_table = &range_ni_E_ao_ext,
.ao_unipolar = 1,
.ao_speed = 1000, .ao_speed = 1000,
.num_p0_dio_channels = 8, .num_p0_dio_channels = 8,
.caldac = { mb88341 }, .caldac = { mb88341 },
...@@ -133,7 +132,6 @@ static const struct ni_board_struct ni_boards[] = { ...@@ -133,7 +132,6 @@ static const struct ni_board_struct ni_boards[] = {
.aobits = 12, .aobits = 12,
.ao_fifo_depth = 2048, .ao_fifo_depth = 2048,
.ao_range_table = &range_ni_E_ao_ext, .ao_range_table = &range_ni_E_ao_ext,
.ao_unipolar = 1,
.ao_speed = 1000, .ao_speed = 1000,
.num_p0_dio_channels = 8, .num_p0_dio_channels = 8,
.caldac = { mb88341 }, .caldac = { mb88341 },
...@@ -149,7 +147,6 @@ static const struct ni_board_struct ni_boards[] = { ...@@ -149,7 +147,6 @@ static const struct ni_board_struct ni_boards[] = {
.n_aochan = 2, .n_aochan = 2,
.aobits = 12, .aobits = 12,
.ao_range_table = &range_ni_E_ao_ext, .ao_range_table = &range_ni_E_ao_ext,
.ao_unipolar = 1,
.ao_speed = 10000, .ao_speed = 10000,
.num_p0_dio_channels = 8, .num_p0_dio_channels = 8,
.caldac = { ad8804_debug }, .caldac = { ad8804_debug },
...@@ -165,7 +162,6 @@ static const struct ni_board_struct ni_boards[] = { ...@@ -165,7 +162,6 @@ static const struct ni_board_struct ni_boards[] = {
.n_aochan = 2, .n_aochan = 2,
.aobits = 12, .aobits = 12,
.ao_range_table = &range_ni_E_ao_ext, .ao_range_table = &range_ni_E_ao_ext,
.ao_unipolar = 1,
.ao_speed = 10000, .ao_speed = 10000,
.num_p0_dio_channels = 8, .num_p0_dio_channels = 8,
.caldac = { ad8804_debug }, .caldac = { ad8804_debug },
...@@ -183,7 +179,6 @@ static const struct ni_board_struct ni_boards[] = { ...@@ -183,7 +179,6 @@ static const struct ni_board_struct ni_boards[] = {
.aobits = 12, .aobits = 12,
.ao_fifo_depth = 2048, .ao_fifo_depth = 2048,
.ao_range_table = &range_ni_E_ao_ext, .ao_range_table = &range_ni_E_ao_ext,
.ao_unipolar = 1,
.ao_speed = 1000, .ao_speed = 1000,
.num_p0_dio_channels = 8, .num_p0_dio_channels = 8,
.caldac = { ad8804_debug }, .caldac = { ad8804_debug },
...@@ -217,7 +212,6 @@ static const struct ni_board_struct ni_boards[] = { ...@@ -217,7 +212,6 @@ static const struct ni_board_struct ni_boards[] = {
.aobits = 16, .aobits = 16,
.ao_fifo_depth = 2048, .ao_fifo_depth = 2048,
.ao_range_table = &range_ni_E_ao_ext, .ao_range_table = &range_ni_E_ao_ext,
.ao_unipolar = 1,
.ao_speed = 1000, .ao_speed = 1000,
.num_p0_dio_channels = 8, .num_p0_dio_channels = 8,
.caldac = { dac8800, dac8043, ad8522 }, .caldac = { dac8800, dac8043, ad8522 },
......
...@@ -2925,7 +2925,8 @@ static void ni_ao_munge(struct comedi_device *dev, struct comedi_subdevice *s, ...@@ -2925,7 +2925,8 @@ static void ni_ao_munge(struct comedi_device *dev, struct comedi_subdevice *s,
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
range = CR_RANGE(cmd->chanlist[chan_index]); range = CR_RANGE(cmd->chanlist[chan_index]);
if (board->ao_unipolar == 0 || (range & 1) == 0)
if (comedi_range_is_bipolar(s, range))
array[i] -= offset; array[i] -= offset;
#ifdef PCIDMA #ifdef PCIDMA
array[i] = cpu_to_le16(array[i]); array[i] = cpu_to_le16(array[i]);
...@@ -3028,19 +3029,14 @@ static int ni_old_ao_config_chanlist(struct comedi_device *dev, ...@@ -3028,19 +3029,14 @@ static int ni_old_ao_config_chanlist(struct comedi_device *dev,
range = CR_RANGE(chanspec[i]); range = CR_RANGE(chanspec[i]);
conf = AO_Channel(chan); conf = AO_Channel(chan);
if (board->ao_unipolar) { if (comedi_range_is_bipolar(s, range)) {
if ((range & 1) == 0) {
conf |= AO_Bipolar;
invert = (1 << (board->aobits - 1));
} else {
invert = 0;
}
if (range & 2)
conf |= AO_Ext_Ref;
} else {
conf |= AO_Bipolar; conf |= AO_Bipolar;
invert = (1 << (board->aobits - 1)); invert = (1 << (board->aobits - 1));
} else {
invert = 0;
} }
if (comedi_range_is_external(s, range))
conf |= AO_Ext_Ref;
/* not all boards can deglitch, but this shouldn't hurt */ /* not all boards can deglitch, but this shouldn't hurt */
if (chanspec[i] & CR_DEGLITCH) if (chanspec[i] & CR_DEGLITCH)
......
...@@ -235,7 +235,6 @@ static const struct ni_board_struct ni_boards[] = { ...@@ -235,7 +235,6 @@ static const struct ni_board_struct ni_boards[] = {
.aobits = 16, .aobits = 16,
.ao_fifo_depth = 2048, .ao_fifo_depth = 2048,
.ao_range_table = &range_ni_E_ao_ext, .ao_range_table = &range_ni_E_ao_ext,
.ao_unipolar = 1,
.ao_speed = 10000, .ao_speed = 10000,
.num_p0_dio_channels = 8, .num_p0_dio_channels = 8,
.caldac = { dac8800, dac8043, ad8522 }, .caldac = { dac8800, dac8043, ad8522 },
...@@ -267,7 +266,6 @@ static const struct ni_board_struct ni_boards[] = { ...@@ -267,7 +266,6 @@ static const struct ni_board_struct ni_boards[] = {
.aobits = 16, .aobits = 16,
.ao_fifo_depth = 2048, .ao_fifo_depth = 2048,
.ao_range_table = &range_ni_E_ao_ext, .ao_range_table = &range_ni_E_ao_ext,
.ao_unipolar = 1,
.ao_speed = 10000, .ao_speed = 10000,
.num_p0_dio_channels = 8, .num_p0_dio_channels = 8,
.caldac = { dac8800, dac8043, ad8522 }, .caldac = { dac8800, dac8043, ad8522 },
...@@ -283,7 +281,6 @@ static const struct ni_board_struct ni_boards[] = { ...@@ -283,7 +281,6 @@ static const struct ni_board_struct ni_boards[] = {
.aobits = 12, .aobits = 12,
.ao_fifo_depth = 2048, .ao_fifo_depth = 2048,
.ao_range_table = &range_ni_E_ao_ext, .ao_range_table = &range_ni_E_ao_ext,
.ao_unipolar = 1,
.ao_speed = 1000, .ao_speed = 1000,
.num_p0_dio_channels = 8, .num_p0_dio_channels = 8,
.caldac = { mb88341 }, .caldac = { mb88341 },
...@@ -303,7 +300,6 @@ static const struct ni_board_struct ni_boards[] = { ...@@ -303,7 +300,6 @@ static const struct ni_board_struct ni_boards[] = {
.aobits = 12, .aobits = 12,
.ao_fifo_depth = 512, .ao_fifo_depth = 512,
.ao_range_table = &range_ni_E_ao_ext, .ao_range_table = &range_ni_E_ao_ext,
.ao_unipolar = 1,
.ao_speed = 1000, .ao_speed = 1000,
.num_p0_dio_channels = 8, .num_p0_dio_channels = 8,
.caldac = { ad8804_debug }, /* doc says mb88341 */ .caldac = { ad8804_debug }, /* doc says mb88341 */
...@@ -319,7 +315,6 @@ static const struct ni_board_struct ni_boards[] = { ...@@ -319,7 +315,6 @@ static const struct ni_board_struct ni_boards[] = {
.aobits = 12, .aobits = 12,
.ao_fifo_depth = 512, .ao_fifo_depth = 512,
.ao_range_table = &range_ni_E_ao_ext, .ao_range_table = &range_ni_E_ao_ext,
.ao_unipolar = 1,
.ao_speed = 1000, .ao_speed = 1000,
.num_p0_dio_channels = 8, .num_p0_dio_channels = 8,
.caldac = { mb88341 }, .caldac = { mb88341 },
...@@ -336,7 +331,6 @@ static const struct ni_board_struct ni_boards[] = { ...@@ -336,7 +331,6 @@ static const struct ni_board_struct ni_boards[] = {
.aobits = 16, .aobits = 16,
.ao_fifo_depth = 2048, .ao_fifo_depth = 2048,
.ao_range_table = &range_ni_E_ao_ext, .ao_range_table = &range_ni_E_ao_ext,
.ao_unipolar = 1,
.ao_speed = 10000, .ao_speed = 10000,
.num_p0_dio_channels = 8, .num_p0_dio_channels = 8,
.caldac = { dac8800, dac8043, ad8522 }, .caldac = { dac8800, dac8043, ad8522 },
...@@ -375,7 +369,6 @@ static const struct ni_board_struct ni_boards[] = { ...@@ -375,7 +369,6 @@ static const struct ni_board_struct ni_boards[] = {
.aobits = 12, .aobits = 12,
.ao_fifo_depth = 2048, .ao_fifo_depth = 2048,
.ao_range_table = &range_ni_E_ao_ext, .ao_range_table = &range_ni_E_ao_ext,
.ao_unipolar = 1,
.ao_speed = 1000, .ao_speed = 1000,
.num_p0_dio_channels = 8, .num_p0_dio_channels = 8,
.caldac = { ad8804_debug }, .caldac = { ad8804_debug },
...@@ -429,7 +422,6 @@ static const struct ni_board_struct ni_boards[] = { ...@@ -429,7 +422,6 @@ static const struct ni_board_struct ni_boards[] = {
.n_aochan = 2, .n_aochan = 2,
.aobits = 12, .aobits = 12,
.ao_range_table = &range_ni_E_ao_ext, .ao_range_table = &range_ni_E_ao_ext,
.ao_unipolar = 1,
.ao_speed = 100000, .ao_speed = 100000,
.num_p0_dio_channels = 8, .num_p0_dio_channels = 8,
.caldac = { ad8804_debug }, /* manual is wrong */ .caldac = { ad8804_debug }, /* manual is wrong */
...@@ -471,7 +463,6 @@ static const struct ni_board_struct ni_boards[] = { ...@@ -471,7 +463,6 @@ static const struct ni_board_struct ni_boards[] = {
.ai_speed = 3000, .ai_speed = 3000,
.n_aochan = 2, .n_aochan = 2,
.aobits = 16, .aobits = 16,
.ao_unipolar = 1,
.ao_fifo_depth = 2048, .ao_fifo_depth = 2048,
.ao_range_table = &range_ni_E_ao_ext, .ao_range_table = &range_ni_E_ao_ext,
.ao_speed = 3000, .ao_speed = 3000,
...@@ -653,7 +644,6 @@ static const struct ni_board_struct ni_boards[] = { ...@@ -653,7 +644,6 @@ static const struct ni_board_struct ni_boards[] = {
.aobits = 12, .aobits = 12,
.ao_fifo_depth = 2048, .ao_fifo_depth = 2048,
.ao_range_table = &range_ni_E_ao_ext, .ao_range_table = &range_ni_E_ao_ext,
.ao_unipolar = 1,
.ao_speed = 1000, .ao_speed = 1000,
.num_p0_dio_channels = 8, .num_p0_dio_channels = 8,
.caldac = { ad8804_debug }, .caldac = { ad8804_debug },
...@@ -670,7 +660,6 @@ static const struct ni_board_struct ni_boards[] = { ...@@ -670,7 +660,6 @@ static const struct ni_board_struct ni_boards[] = {
.aobits = 12, .aobits = 12,
.ao_fifo_depth = 2048, .ao_fifo_depth = 2048,
.ao_range_table = &range_ni_E_ao_ext, .ao_range_table = &range_ni_E_ao_ext,
.ao_unipolar = 1,
.ao_speed = 1000, .ao_speed = 1000,
.num_p0_dio_channels = 8, .num_p0_dio_channels = 8,
.caldac = { ad8804_debug }, .caldac = { ad8804_debug },
...@@ -685,7 +674,6 @@ static const struct ni_board_struct ni_boards[] = { ...@@ -685,7 +674,6 @@ static const struct ni_board_struct ni_boards[] = {
.ai_speed = 3000, .ai_speed = 3000,
.n_aochan = 2, .n_aochan = 2,
.aobits = 16, .aobits = 16,
.ao_unipolar = 1,
.ao_fifo_depth = 2048, .ao_fifo_depth = 2048,
.ao_range_table = &range_ni_E_ao_ext, .ao_range_table = &range_ni_E_ao_ext,
.ao_speed = 3000, .ao_speed = 3000,
...@@ -704,7 +692,6 @@ static const struct ni_board_struct ni_boards[] = { ...@@ -704,7 +692,6 @@ static const struct ni_board_struct ni_boards[] = {
.aobits = 16, .aobits = 16,
.ao_fifo_depth = 2048, .ao_fifo_depth = 2048,
.ao_range_table = &range_ni_E_ao_ext, .ao_range_table = &range_ni_E_ao_ext,
.ao_unipolar = 1,
.ao_speed = 10000, .ao_speed = 10000,
.num_p0_dio_channels = 8, .num_p0_dio_channels = 8,
.caldac = { dac8800, dac8043, ad8522 }, .caldac = { dac8800, dac8043, ad8522 },
...@@ -963,7 +950,6 @@ static const struct ni_board_struct ni_boards[] = { ...@@ -963,7 +950,6 @@ static const struct ni_board_struct ni_boards[] = {
.ao_fifo_depth = 8191, .ao_fifo_depth = 8191,
.ao_range_table = &range_ni_M_628x_ao, .ao_range_table = &range_ni_M_628x_ao,
.reg_type = ni_reg_628x, .reg_type = ni_reg_628x,
.ao_unipolar = 1,
.ao_speed = 350, .ao_speed = 350,
.num_p0_dio_channels = 8, .num_p0_dio_channels = 8,
.caldac = { caldac_none }, .caldac = { caldac_none },
...@@ -980,7 +966,6 @@ static const struct ni_board_struct ni_boards[] = { ...@@ -980,7 +966,6 @@ static const struct ni_board_struct ni_boards[] = {
.ao_fifo_depth = 8191, .ao_fifo_depth = 8191,
.ao_range_table = &range_ni_M_628x_ao, .ao_range_table = &range_ni_M_628x_ao,
.reg_type = ni_reg_628x, .reg_type = ni_reg_628x,
.ao_unipolar = 1,
.ao_speed = 350, .ao_speed = 350,
.num_p0_dio_channels = 8, .num_p0_dio_channels = 8,
.caldac = { caldac_none }, .caldac = { caldac_none },
...@@ -1008,7 +993,6 @@ static const struct ni_board_struct ni_boards[] = { ...@@ -1008,7 +993,6 @@ static const struct ni_board_struct ni_boards[] = {
.ao_fifo_depth = 8191, .ao_fifo_depth = 8191,
.ao_range_table = &range_ni_M_628x_ao, .ao_range_table = &range_ni_M_628x_ao,
.reg_type = ni_reg_628x, .reg_type = ni_reg_628x,
.ao_unipolar = 1,
.ao_speed = 350, .ao_speed = 350,
.num_p0_dio_channels = 32, .num_p0_dio_channels = 32,
.caldac = { caldac_none }, .caldac = { caldac_none },
......
...@@ -1409,7 +1409,6 @@ struct ni_board_struct { ...@@ -1409,7 +1409,6 @@ struct ni_board_struct {
unsigned num_p0_dio_channels; unsigned num_p0_dio_channels;
int reg_type; int reg_type;
unsigned int ao_unipolar:1;
unsigned int has_8255:1; unsigned int has_8255:1;
unsigned int has_analog_trig:1; unsigned int has_analog_trig:1;
......
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