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:47 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-03-28 07:30:36 -0700
commit34b7f1f8194da6600eda6bb7c26659de19047a39 (patch)
tree399ecb9f3c5e30add65d0944f0681134d4e073af /drivers/staging/comedi/drivers/ni_660x.c
parent90ad57be6be10e7084ca677d6eddfba612b55a62 (diff)
staging: comedi: ni_660x: default DIO channels with subdevice init
For aesthetics, move the initialization of the default routing for the DIO channels so it happens when the subdevice is initialized. 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.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/drivers/staging/comedi/drivers/ni_660x.c b/drivers/staging/comedi/drivers/ni_660x.c
index 5969723b6167..cf25892d92b2 100644
--- a/drivers/staging/comedi/drivers/ni_660x.c
+++ b/drivers/staging/comedi/drivers/ni_660x.c
@@ -996,6 +996,19 @@ static int ni_660x_auto_attach(struct comedi_device *dev,
s->insn_bits = ni_660x_dio_insn_bits;
s->insn_config = ni_660x_dio_insn_config;
+ /*
+ * Default the DIO channels as:
+ * chan 0-7: DIO inputs
+ * chan 8-39: counter signal inputs
+ */
+ for (i = 0; i < s->n_chan; ++i) {
+ unsigned int source = (i < 8) ? NI_660X_PFI_OUTPUT_DIO
+ : NI_660X_PFI_OUTPUT_COUNTER;
+
+ ni_660x_set_pfi_routing(dev, i, source);
+ ni_660x_select_pfi_output(dev, i, 0); /* high-z */
+ }
+
/* Counter subdevices (4 NI TIO General Purpose Counters per chip) */
for (i = 0; i < NI660X_MAX_COUNTERS; ++i) {
s = &dev->subdevices[subdev++];
@@ -1028,20 +1041,6 @@ static int ni_660x_auto_attach(struct comedi_device *dev,
}
}
- /*
- * Default the DIO channels as:
- * chan 0-7: DIO inputs
- * chan 8-39: counter signal inputs
- */
- for (i = 0; i < NI660X_NUM_PFI_CHANNELS; ++i) {
- if (i < 8)
- ni_660x_set_pfi_routing(dev, i, NI_660X_PFI_OUTPUT_DIO);
- else
- ni_660x_set_pfi_routing(dev, i,
- NI_660X_PFI_OUTPUT_COUNTER);
- ni_660x_select_pfi_output(dev, i, 0); /* high-z */
- }
-
/*
* To be safe, set counterswap bits on tio chips after all the counter
* outputs have been set to high impedance mode.