aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH Hartley Sweeten <[email protected]>2015-08-12 13:25:39 -0700
committerGreg Kroah-Hartman <[email protected]>2015-08-14 18:36:17 -0700
commit626bb280d0516c7b4adee50cdd2b8ea377183f46 (patch)
tree3d70c7e6a9da8da3ba083087e834d7a0ec2e24c2
parente078d25639c0f8a5d97c879e276a2eba877dce62 (diff)
staging: comedi: hwdrv_apci3501: refactor apci3501_write_insn_timer()
The handling of the ADDIDATA_WATCHDOG and ADDIDATA_TIMER is identical except for the "stop" operation. Refactor this function to use a common code path for both timer modes. Signed-off-by: H Hartley Sweeten <[email protected]> Reviewed-by: Ian Abbott <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
-rw-r--r--drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c48
1 files changed, 13 insertions, 35 deletions
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
index 306309ed9637..6d0cf6dbca49 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3501.c
@@ -92,46 +92,24 @@ static int apci3501_write_insn_timer(struct comedi_device *dev,
unsigned int *data)
{
struct apci3501_private *devpriv = dev->private;
- unsigned int ctrl = 0;
+ unsigned int ctrl;
- if (devpriv->timer_mode == ADDIDATA_WATCHDOG) {
- if (data[1] == 1) {
- ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
- ctrl &= 0xfffff9ff;
- ctrl |= 0x1;
- /* Enable the Watchdog */
- outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
- } else if (data[1] == 0) { /* Stop The Watchdog */
- outl(0x0, dev->iobase + APCI3501_TIMER_CTRL_REG);
- } else if (data[1] == 2) {
- ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
- ctrl &= 0xfffff9ff;
- ctrl |= 0x200;
- outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
- }
- }
+ if (devpriv->timer_mode == ADDIDATA_WATCHDOG ||
+ devpriv->timer_mode == ADDIDATA_TIMER) {
+ ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
+ ctrl &= 0xfffff9ff;
- if (devpriv->timer_mode == ADDIDATA_TIMER) {
- if (data[1] == 1) {
- ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
- ctrl &= 0xfffff9ff;
+ if (data[1] == 1) { /* enable */
ctrl |= 0x1;
- /* Enable the Timer */
- outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
- } else if (data[1] == 0) {
- /* Stop The Timer */
- ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
- ctrl &= 0xfffff9fe;
- outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
- }
-
- else if (data[1] == 2) {
- /* Trigger the Timer */
- ctrl = inl(dev->iobase + APCI3501_TIMER_CTRL_REG);
- ctrl &= 0xfffff9ff;
+ } else if (data[1] == 0) { /* stop */
+ if (devpriv->timer_mode == ADDIDATA_WATCHDOG)
+ ctrl = 0;
+ else
+ ctrl &= ~0x1;
+ } else if (data[1] == 2) { /* trigger */
ctrl |= 0x200;
- outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
}
+ outl(ctrl, dev->iobase + APCI3501_TIMER_CTRL_REG);
}
inl(dev->iobase + APCI3501_TIMER_STATUS_REG);