[PATCH 07/28] staging: comedi: ni_tio_internal: simplify ni_tio_counting_mode_registers_present()

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

 



Only the e series gpct variant does not have counting mode registers.
Simplfy this function. For aesthetics, return bool instead of int.

This fixes the checkpatch.pl issues:
CHECK: spaces preferred around that '*' (ctx:ExV)
CHECK: Avoid crashing the kernel - try using WARN_ON & recovery code
       rather than BUG() or BUG_ON()

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          |  2 +-
 drivers/staging/comedi/drivers/ni_tio_internal.h | 18 ++++--------------
 2 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c
index 5343fce..44dea4c 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -451,7 +451,7 @@ static void ni_tio_set_sync_mode(struct ni_gpct *counter, int force_alt_sync)
 	unsigned mode;
 	uint64_t clock_period_ps;
 
-	if (ni_tio_counting_mode_registers_present(counter_dev) == 0)
+	if (!ni_tio_counting_mode_registers_present(counter_dev))
 		return;
 
 	mode = ni_tio_get_soft_copy(counter, counting_mode_reg);
diff --git a/drivers/staging/comedi/drivers/ni_tio_internal.h b/drivers/staging/comedi/drivers/ni_tio_internal.h
index c8ad66a..1e795fd 100644
--- a/drivers/staging/comedi/drivers/ni_tio_internal.h
+++ b/drivers/staging/comedi/drivers/ni_tio_internal.h
@@ -174,21 +174,11 @@ static inline unsigned read_register(struct ni_gpct *counter,
 	return counter->counter_dev->read_register(counter, reg);
 }
 
-static inline int ni_tio_counting_mode_registers_present(const struct
-							 ni_gpct_device
-							 *counter_dev)
+static inline bool
+ni_tio_counting_mode_registers_present(const struct ni_gpct_device *counter_dev)
 {
-	switch (counter_dev->variant) {
-	case ni_gpct_variant_e_series:
-		return 0;
-	case ni_gpct_variant_m_series:
-	case ni_gpct_variant_660x:
-		return 1;
-	default:
-		BUG();
-		break;
-	}
-	return 0;
+	/* m series and 660x variants have counting mode registers */
+	return counter_dev->variant != ni_gpct_variant_e_series;
 }
 
 void ni_tio_set_bits(struct ni_gpct *, enum ni_gpct_register reg,
-- 
2.6.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