[PATCH 34/40] staging: comedi: ni_tio: tidy up ni_tio_set_other_src()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Invert the counter_dev->variant test to reduce the indent level of
this function.

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 drivers/staging/comedi/drivers/ni_tio.c | 50 ++++++++++++++++-----------------
 1 file changed, 24 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c
index a149a73..1982a25 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -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)
-- 
1.9.3

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux