From fed3c23b5e3c56e358e751418d7310b9c8e926cc Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 14 Jul 2014 12:23:40 -0700 Subject: [PATCH] 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: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_atmio.c | 6 ------ drivers/staging/comedi/drivers/ni_mio_common.c | 18 +++++++----------- drivers/staging/comedi/drivers/ni_pcimio.c | 16 ---------------- drivers/staging/comedi/drivers/ni_stc.h | 1 - 4 files changed, 7 insertions(+), 34 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_atmio.c b/drivers/staging/comedi/drivers/ni_atmio.c index d7ee6bd..0f4dc5a 100644 --- a/drivers/staging/comedi/drivers/ni_atmio.c +++ b/drivers/staging/comedi/drivers/ni_atmio.c @@ -116,7 +116,6 @@ static const struct ni_board_struct ni_boards[] = { .aobits = 12, .ao_fifo_depth = 2048, .ao_range_table = &range_ni_E_ao_ext, - .ao_unipolar = 1, .ao_speed = 1000, .num_p0_dio_channels = 8, .caldac = { mb88341 }, @@ -133,7 +132,6 @@ static const struct ni_board_struct ni_boards[] = { .aobits = 12, .ao_fifo_depth = 2048, .ao_range_table = &range_ni_E_ao_ext, - .ao_unipolar = 1, .ao_speed = 1000, .num_p0_dio_channels = 8, .caldac = { mb88341 }, @@ -149,7 +147,6 @@ static const struct ni_board_struct ni_boards[] = { .n_aochan = 2, .aobits = 12, .ao_range_table = &range_ni_E_ao_ext, - .ao_unipolar = 1, .ao_speed = 10000, .num_p0_dio_channels = 8, .caldac = { ad8804_debug }, @@ -165,7 +162,6 @@ static const struct ni_board_struct ni_boards[] = { .n_aochan = 2, .aobits = 12, .ao_range_table = &range_ni_E_ao_ext, - .ao_unipolar = 1, .ao_speed = 10000, .num_p0_dio_channels = 8, .caldac = { ad8804_debug }, @@ -183,7 +179,6 @@ static const struct ni_board_struct ni_boards[] = { .aobits = 12, .ao_fifo_depth = 2048, .ao_range_table = &range_ni_E_ao_ext, - .ao_unipolar = 1, .ao_speed = 1000, .num_p0_dio_channels = 8, .caldac = { ad8804_debug }, @@ -217,7 +212,6 @@ static const struct ni_board_struct ni_boards[] = { .aobits = 16, .ao_fifo_depth = 2048, .ao_range_table = &range_ni_E_ao_ext, - .ao_unipolar = 1, .ao_speed = 1000, .num_p0_dio_channels = 8, .caldac = { dac8800, dac8043, ad8522 }, diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index ff881a7..471d7af 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -2925,7 +2925,8 @@ static void ni_ao_munge(struct comedi_device *dev, struct comedi_subdevice *s, for (i = 0; i < length; i++) { 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; #ifdef PCIDMA array[i] = cpu_to_le16(array[i]); @@ -3028,19 +3029,14 @@ static int ni_old_ao_config_chanlist(struct comedi_device *dev, range = CR_RANGE(chanspec[i]); conf = AO_Channel(chan); - if (board->ao_unipolar) { - if ((range & 1) == 0) { - conf |= AO_Bipolar; - invert = (1 << (board->aobits - 1)); - } else { - invert = 0; - } - if (range & 2) - conf |= AO_Ext_Ref; - } else { + if (comedi_range_is_bipolar(s, range)) { conf |= AO_Bipolar; 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 */ if (chanspec[i] & CR_DEGLITCH) diff --git a/drivers/staging/comedi/drivers/ni_pcimio.c b/drivers/staging/comedi/drivers/ni_pcimio.c index 20c839b..f7e73a7 100644 --- a/drivers/staging/comedi/drivers/ni_pcimio.c +++ b/drivers/staging/comedi/drivers/ni_pcimio.c @@ -235,7 +235,6 @@ static const struct ni_board_struct ni_boards[] = { .aobits = 16, .ao_fifo_depth = 2048, .ao_range_table = &range_ni_E_ao_ext, - .ao_unipolar = 1, .ao_speed = 10000, .num_p0_dio_channels = 8, .caldac = { dac8800, dac8043, ad8522 }, @@ -267,7 +266,6 @@ static const struct ni_board_struct ni_boards[] = { .aobits = 16, .ao_fifo_depth = 2048, .ao_range_table = &range_ni_E_ao_ext, - .ao_unipolar = 1, .ao_speed = 10000, .num_p0_dio_channels = 8, .caldac = { dac8800, dac8043, ad8522 }, @@ -283,7 +281,6 @@ static const struct ni_board_struct ni_boards[] = { .aobits = 12, .ao_fifo_depth = 2048, .ao_range_table = &range_ni_E_ao_ext, - .ao_unipolar = 1, .ao_speed = 1000, .num_p0_dio_channels = 8, .caldac = { mb88341 }, @@ -303,7 +300,6 @@ static const struct ni_board_struct ni_boards[] = { .aobits = 12, .ao_fifo_depth = 512, .ao_range_table = &range_ni_E_ao_ext, - .ao_unipolar = 1, .ao_speed = 1000, .num_p0_dio_channels = 8, .caldac = { ad8804_debug }, /* doc says mb88341 */ @@ -319,7 +315,6 @@ static const struct ni_board_struct ni_boards[] = { .aobits = 12, .ao_fifo_depth = 512, .ao_range_table = &range_ni_E_ao_ext, - .ao_unipolar = 1, .ao_speed = 1000, .num_p0_dio_channels = 8, .caldac = { mb88341 }, @@ -336,7 +331,6 @@ static const struct ni_board_struct ni_boards[] = { .aobits = 16, .ao_fifo_depth = 2048, .ao_range_table = &range_ni_E_ao_ext, - .ao_unipolar = 1, .ao_speed = 10000, .num_p0_dio_channels = 8, .caldac = { dac8800, dac8043, ad8522 }, @@ -375,7 +369,6 @@ static const struct ni_board_struct ni_boards[] = { .aobits = 12, .ao_fifo_depth = 2048, .ao_range_table = &range_ni_E_ao_ext, - .ao_unipolar = 1, .ao_speed = 1000, .num_p0_dio_channels = 8, .caldac = { ad8804_debug }, @@ -429,7 +422,6 @@ static const struct ni_board_struct ni_boards[] = { .n_aochan = 2, .aobits = 12, .ao_range_table = &range_ni_E_ao_ext, - .ao_unipolar = 1, .ao_speed = 100000, .num_p0_dio_channels = 8, .caldac = { ad8804_debug }, /* manual is wrong */ @@ -471,7 +463,6 @@ static const struct ni_board_struct ni_boards[] = { .ai_speed = 3000, .n_aochan = 2, .aobits = 16, - .ao_unipolar = 1, .ao_fifo_depth = 2048, .ao_range_table = &range_ni_E_ao_ext, .ao_speed = 3000, @@ -653,7 +644,6 @@ static const struct ni_board_struct ni_boards[] = { .aobits = 12, .ao_fifo_depth = 2048, .ao_range_table = &range_ni_E_ao_ext, - .ao_unipolar = 1, .ao_speed = 1000, .num_p0_dio_channels = 8, .caldac = { ad8804_debug }, @@ -670,7 +660,6 @@ static const struct ni_board_struct ni_boards[] = { .aobits = 12, .ao_fifo_depth = 2048, .ao_range_table = &range_ni_E_ao_ext, - .ao_unipolar = 1, .ao_speed = 1000, .num_p0_dio_channels = 8, .caldac = { ad8804_debug }, @@ -685,7 +674,6 @@ static const struct ni_board_struct ni_boards[] = { .ai_speed = 3000, .n_aochan = 2, .aobits = 16, - .ao_unipolar = 1, .ao_fifo_depth = 2048, .ao_range_table = &range_ni_E_ao_ext, .ao_speed = 3000, @@ -704,7 +692,6 @@ static const struct ni_board_struct ni_boards[] = { .aobits = 16, .ao_fifo_depth = 2048, .ao_range_table = &range_ni_E_ao_ext, - .ao_unipolar = 1, .ao_speed = 10000, .num_p0_dio_channels = 8, .caldac = { dac8800, dac8043, ad8522 }, @@ -963,7 +950,6 @@ static const struct ni_board_struct ni_boards[] = { .ao_fifo_depth = 8191, .ao_range_table = &range_ni_M_628x_ao, .reg_type = ni_reg_628x, - .ao_unipolar = 1, .ao_speed = 350, .num_p0_dio_channels = 8, .caldac = { caldac_none }, @@ -980,7 +966,6 @@ static const struct ni_board_struct ni_boards[] = { .ao_fifo_depth = 8191, .ao_range_table = &range_ni_M_628x_ao, .reg_type = ni_reg_628x, - .ao_unipolar = 1, .ao_speed = 350, .num_p0_dio_channels = 8, .caldac = { caldac_none }, @@ -1008,7 +993,6 @@ static const struct ni_board_struct ni_boards[] = { .ao_fifo_depth = 8191, .ao_range_table = &range_ni_M_628x_ao, .reg_type = ni_reg_628x, - .ao_unipolar = 1, .ao_speed = 350, .num_p0_dio_channels = 32, .caldac = { caldac_none }, diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 02a7fa3..b3799f3 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -1409,7 +1409,6 @@ struct ni_board_struct { unsigned num_p0_dio_channels; int reg_type; - unsigned int ao_unipolar:1; unsigned int has_8255:1; unsigned int has_analog_trig:1; -- 2.7.4