[PATCH 13/15] staging: comedi: hwdrv_apci3501: remove "magic" numbers in apci3501_config_insn_timer()

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

 



Use register bit defines from addi_tcw.h to remove the "magic" numbers.

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 .../staging/comedi/drivers/addi-data/hwdrv_apci3501.c  | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
index 8ba094c..c4a72a5 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
@@ -37,12 +37,13 @@ static int apci3501_config_insn_timer(struct comedi_device *dev,
 		ctrl = 0;
 	} else {
 		ctrl = inl(devpriv->tcw + ADDI_TCW_CTRL_REG);
-		ctrl &= 0xfffff9fe;
+		ctrl &= ~(ADDI_TCW_CTRL_GATE | ADDI_TCW_CTRL_TRIG |
+			  ADDI_TCW_CTRL_ENA);
 	}
 	outl(ctrl, devpriv->tcw + ADDI_TCW_CTRL_REG);
 
 	/* enable/disable the timer interrupt */
-	ctrl = (data[1] == 1) ? 0x2 : 0;
+	ctrl = (data[1] == 1) ? ADDI_TCW_CTRL_IRQ_ENA : 0;
 	outl(ctrl, devpriv->tcw + ADDI_TCW_CTRL_REG);
 
 	outl(data[2], devpriv->tcw + ADDI_TCW_TIMEBASE_REG);
@@ -51,11 +52,18 @@ static int apci3501_config_insn_timer(struct comedi_device *dev,
 	ctrl = inl(devpriv->tcw + ADDI_TCW_CTRL_REG);
 	if (devpriv->timer_mode == ADDIDATA_WATCHDOG) {
 		/* Set the mode (e2->e0) NOTE: this doesn't look correct */
-		ctrl |= 0xfff819e0;
+		ctrl |= ~(ADDI_TCW_CTRL_CNT_UP | ADDI_TCW_CTRL_EXT_CLK_MASK |
+			  ADDI_TCW_CTRL_MODE_MASK | ADDI_TCW_CTRL_GATE |
+			  ADDI_TCW_CTRL_TRIG | ADDI_TCW_CTRL_TIMER_ENA |
+			  ADDI_TCW_CTRL_RESET_ENA | ADDI_TCW_CTRL_WARN_ENA |
+			  ADDI_TCW_CTRL_IRQ_ENA | ADDI_TCW_CTRL_ENA);
 	} else {
 		/* mode 2 */
-		ctrl &= 0xfff719e2;
-		ctrl |= (2 << 13) | 0x10;
+		ctrl &= ~(ADDI_TCW_CTRL_CNTR_ENA | ADDI_TCW_CTRL_MODE_MASK |
+			  ADDI_TCW_CTRL_GATE | ADDI_TCW_CTRL_TRIG |
+			  ADDI_TCW_CTRL_TIMER_ENA | ADDI_TCW_CTRL_RESET_ENA |
+			  ADDI_TCW_CTRL_WARN_ENA | ADDI_TCW_CTRL_ENA);
+		ctrl |= ADDI_TCW_CTRL_MODE(2) | ADDI_TCW_CTRL_TIMER_ENA;
 	}
 	outl(ctrl, devpriv->tcw + ADDI_TCW_CTRL_REG);
 
-- 
2.4.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