summaryrefslogtreecommitdiff
path: root/drivers/staging/comedi/drivers/ni_660x.c
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2016-03-22 11:10:24 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-03-28 07:30:36 -0700
commit518d38423b48ad23b2f4b13dd9a027aa37423f1d (patch)
tree905a83d5a91300cabd42974d3bcec78e8705d932 /drivers/staging/comedi/drivers/ni_660x.c
parentdc285820cc19a666aea45ac74e9737c2afcf8189 (diff)
staging: comedi: ni_660x: tidy up ni_660x_select_pfi_output()
Tidy up this function to fix the checkpatch.pl issues: WARNING: Prefer 'unsigned int' to bare use of 'unsigned' For aesthetics, remove the static const local variables. 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>
Diffstat (limited to 'drivers/staging/comedi/drivers/ni_660x.c')
-rw-r--r--drivers/staging/comedi/drivers/ni_660x.c54
1 files changed, 24 insertions, 30 deletions
diff --git a/drivers/staging/comedi/drivers/ni_660x.c b/drivers/staging/comedi/drivers/ni_660x.c
index e0532f4d6bc7..79678af8e02c 100644
--- a/drivers/staging/comedi/drivers/ni_660x.c
+++ b/drivers/staging/comedi/drivers/ni_660x.c
@@ -817,46 +817,40 @@ static int ni_660x_dio_insn_bits(struct comedi_device *dev,
}
static void ni_660x_select_pfi_output(struct comedi_device *dev,
- unsigned pfi_channel,
- unsigned output_select)
+ unsigned int chan, unsigned int out_sel)
{
const struct ni_660x_board *board = dev->board_ptr;
- static const unsigned counter_4_7_first_pfi = 8;
- static const unsigned counter_4_7_last_pfi = 23;
- unsigned active_chipset = 0;
- unsigned idle_chipset = 0;
- unsigned active_bits;
- unsigned idle_bits;
+ unsigned int active_chip = 0;
+ unsigned int idle_chip = 0;
+ unsigned int bits;
if (board->n_chips > 1) {
- if (output_select == NI660X_IO_CFG_OUT_SEL_COUNTER &&
- pfi_channel >= counter_4_7_first_pfi &&
- pfi_channel <= counter_4_7_last_pfi) {
- active_chipset = 1;
- idle_chipset = 0;
+ if (out_sel == NI660X_IO_CFG_OUT_SEL_COUNTER &&
+ chan >= 8 && chan <= 23) {
+ /* counters 4-7 pfi channels */
+ active_chip = 1;
+ idle_chip = 0;
} else {
- active_chipset = 0;
- idle_chipset = 1;
+ /* counters 0-3 pfi channels */
+ active_chip = 0;
+ idle_chip = 1;
}
}
- if (idle_chipset != active_chipset) {
- idle_bits = ni_660x_read(dev, idle_chipset,
- NI660X_IO_CFG(pfi_channel));
- idle_bits &= ~NI660X_IO_CFG_OUT_SEL_MASK(pfi_channel);
- idle_bits |=
- NI660X_IO_CFG_OUT_SEL(pfi_channel,
- NI660X_IO_CFG_OUT_SEL_HIGH_Z);
- ni_660x_write(dev, idle_chipset, idle_bits,
- NI660X_IO_CFG(pfi_channel));
+ if (idle_chip != active_chip) {
+ /* set the pfi channel to high-z on the inactive chip */
+ bits = ni_660x_read(dev, idle_chip, NI660X_IO_CFG(chan));
+ bits &= ~NI660X_IO_CFG_OUT_SEL_MASK(chan);
+ bits |= NI660X_IO_CFG_OUT_SEL(chan,
+ NI660X_IO_CFG_OUT_SEL_HIGH_Z);
+ ni_660x_write(dev, idle_chip, bits, NI660X_IO_CFG(chan));
}
- active_bits = ni_660x_read(dev, active_chipset,
- NI660X_IO_CFG(pfi_channel));
- active_bits &= ~NI660X_IO_CFG_OUT_SEL_MASK(pfi_channel);
- active_bits |= NI660X_IO_CFG_OUT_SEL(pfi_channel, output_select);
- ni_660x_write(dev, active_chipset, active_bits,
- NI660X_IO_CFG(pfi_channel));
+ /* set the pfi channel output on the active chip */
+ bits = ni_660x_read(dev, active_chip, NI660X_IO_CFG(chan));
+ bits &= ~NI660X_IO_CFG_OUT_SEL_MASK(chan);
+ bits |= NI660X_IO_CFG_OUT_SEL(chan, out_sel);
+ ni_660x_write(dev, active_chip, bits, NI660X_IO_CFG(chan));
}
static int ni_660x_set_pfi_routing(struct comedi_device *dev, unsigned chan,