staging: comedi: ni_stc.h: remove 'ao_unipolar' flag from ni_board_struct
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 14 Jul 2014 19:23:40 +0000 (12:23 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Jul 2014 20:24:41 +0000 (13:24 -0700)
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 <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/ni_atmio.c
drivers/staging/comedi/drivers/ni_mio_common.c
drivers/staging/comedi/drivers/ni_pcimio.c
drivers/staging/comedi/drivers/ni_stc.h

index d7ee6bde44cdedfe8474a5b00de2dfa44bf410cf..0f4dc5afd493f8f6769b6c8332ca9a9faab59e65 100644 (file)
@@ -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 },
index ff881a7afdd309146b32202bc856502b74c99e07..471d7af59e99b4087fee8480a96f5ced48cb98f0 100644 (file)
@@ -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)
index 20c839b45752dbb1f8236503820e8b98503bd0cb..f7e73a77a2dda2974d41fc788bc45a90d7d06c0d 100644 (file)
@@ -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 },
index 02a7fa3233e1cf45f446206c54135c5a8a395504..b3799f3bad28d4990e80f05c5ab27f8b0b179281 100644 (file)
@@ -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;
 
This page took 0.032776 seconds and 5 git commands to generate.