staging: comedi: ni_tio: tidy up ni_tio_set_other_src()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Thu, 24 Jul 2014 17:14:59 +0000 (10:14 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 27 Jul 2014 18:16:48 +0000 (11:16 -0700)
Invert the counter_dev->variant test to reduce the indent level of
this function.

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_tio.c

index a149a73513eb07c7eacb6679162050fc2bbdc1cb..1982a259a872473287c63eaa5b58a110dbe282a5 100644 (file)
@@ -1022,35 +1022,33 @@ static int ni_tio_set_other_src(struct ni_gpct *counter, unsigned index,
 {
        struct ni_gpct_device *counter_dev = counter->counter_dev;
        unsigned cidx = counter->counter_index;
+       unsigned int abz_reg, shift, mask;
 
-       if (counter_dev->variant == ni_gpct_variant_m_series) {
-               unsigned int abz_reg, shift, mask;
+       if (counter_dev->variant != ni_gpct_variant_m_series)
+               return -EINVAL;
 
-               abz_reg = NITIO_ABZ_REG(cidx);
-               switch (index) {
-               case NI_GPCT_SOURCE_ENCODER_A:
-                       shift = 10;
-                       break;
-               case NI_GPCT_SOURCE_ENCODER_B:
-                       shift = 5;
-                       break;
-               case NI_GPCT_SOURCE_ENCODER_Z:
-                       shift = 0;
-                       break;
-               default:
-                       return -EINVAL;
-               }
-               mask = 0x1f << shift;
-               if (source > 0x1f) {
-                       /* Disable gate */
-                       source = 0x1f;
-               }
-               counter_dev->regs[abz_reg] &= ~mask;
-               counter_dev->regs[abz_reg] |= (source << shift) & mask;
-               write_register(counter, counter_dev->regs[abz_reg], abz_reg);
-               return 0;
+       abz_reg = NITIO_ABZ_REG(cidx);
+       switch (index) {
+       case NI_GPCT_SOURCE_ENCODER_A:
+               shift = 10;
+               break;
+       case NI_GPCT_SOURCE_ENCODER_B:
+               shift = 5;
+               break;
+       case NI_GPCT_SOURCE_ENCODER_Z:
+               shift = 0;
+               break;
+       default:
+               return -EINVAL;
        }
-       return -EINVAL;
+       mask = 0x1f << shift;
+       if (source > 0x1f)
+               source = 0x1f;  /* Disable gate */
+
+       counter_dev->regs[abz_reg] &= ~mask;
+       counter_dev->regs[abz_reg] |= (source << shift) & mask;
+       write_register(counter, counter_dev->regs[abz_reg], abz_reg);
+       return 0;
 }
 
 static unsigned ni_660x_gate_to_generic_gate(unsigned gate)