[PATCH 01/11] staging: comedi: s626: clock polarity and direction are the same

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

 



When setting up an encoder channel, the setup value includes a polarity
and direction, but these are the same bit of the setup value:

  S626_CLKPOL_POS = S626_CNTDIR_UP = 0

  S626_CLKPOL_NEG = S626_CNTDIR_DOWN = 1

In the construction of the setup value, both the CLKPOL and the CNTDIR
constants are shifted by the same amount `S626_BF_CLKPOL`.  Only the
following combinations are set up currently (this may change if user
configuration of the encoder is implemented properly):

  (S626_CLKPOL_POS << S626_BF_CLKPOL)

  (S626_CLKPOL_POS << S626_BF_CLKPOL) |
  (S626_CNTDIR_UP << S626_BF_CLKPOL)

  (S626_CLKPOL_POS << S626_BF_CLKPOL) |
  (S626_CNTDIR_DOWN << S626_BF_CLKPOL)

The first two are used in "counter" mode and is equivalent to:

  (S626_CLKPOL_POS << S626_BF_CLKPOL)

The last one is used in "timer" mode and is equivalent to:

  (S626_CNTDIR_DOWN << S626_BF_CLKPOL)

Use the shorter equivalents.  The comments in "s626.h" indicate that the
'CLKPOL' constants make more sense for the "counter" mode (when the
encoders operate as up/down counters) and the 'CNTDIR' constants make
more sense for the "timer" mode.

Signed-off-by: Ian Abbott <abbotti@xxxxxxxxx>
---
 drivers/staging/comedi/drivers/s626.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c
index d9aba7c..dd138a0 100644
--- a/drivers/staging/comedi/drivers/s626.c
+++ b/drivers/staging/comedi/drivers/s626.c
@@ -2036,8 +2036,6 @@ static void s626_timer_load(struct comedi_device *dev,
 		(S626_INDXSRC_SOFT << S626_BF_INDXSRC) |
 		/* Operating mode is Timer. */
 		(S626_CLKSRC_TIMER << S626_BF_CLKSRC) |
-		/* Active high clock. */
-		(S626_CLKPOL_POS << S626_BF_CLKPOL) |
 		/* Count direction is Down. */
 		(S626_CNTDIR_DOWN << S626_BF_CLKPOL) |
 		/* Clock multiplier is 1x. */
@@ -2528,8 +2526,6 @@ static void s626_counters_init(struct comedi_device *dev)
 		(S626_CLKSRC_COUNTER << S626_BF_CLKSRC) |
 		/* Active high clock. */
 		(S626_CLKPOL_POS << S626_BF_CLKPOL) |
-		/* Count direction is up. */
-		(S626_CNTDIR_UP << S626_BF_CLKPOL) |
 		/* Clock multiplier is 1x. */
 		(S626_CLKMULT_1X << S626_BF_CLKMULT) |
 		/* Enabled by index */
-- 
1.8.4

_______________________________________________
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