From: H Hartley Sweeten Date: Tue, 4 Nov 2014 17:53:53 +0000 (-0700) Subject: staging: comedi: addi_apci_3120: tidy up timer_mode masking X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=2016c534dd2f4b0599e5a8513567a34d4746cdf6;p=linux-beck.git staging: comedi: addi_apci_3120: tidy up timer_mode masking Define a macro that returns the mask of the timer_mode bits for a given timer. Use the macro to remove the "magic" values used to clear the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index 546c4c373550..a876adae58d2 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -373,7 +373,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, return -EINVAL; /* Initialize Timer 0 mode 4 */ - devpriv->timer_mode &= 0xfc; + devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(0); devpriv->timer_mode |= APCI3120_TIMER_0_MODE_4; outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); @@ -456,7 +456,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, return -EINVAL; /* Initialize Timer 0 mode 2 */ - devpriv->timer_mode &= 0xfc; + devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(0); devpriv->timer_mode |= APCI3120_TIMER_0_MODE_2; outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); @@ -755,7 +755,7 @@ static int apci3120_cyclic_ai(int mode, switch (mode) { case 1: /* init timer0 in mode 2 */ - devpriv->timer_mode &= 0xfc; + devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(0); devpriv->timer_mode |= APCI3120_TIMER_0_MODE_2; outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); @@ -765,7 +765,7 @@ static int apci3120_cyclic_ai(int mode, case 2: /* init timer1 in mode 2 */ - devpriv->timer_mode &= 0xf3; + devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(1); devpriv->timer_mode |= APCI3120_TIMER_1_MODE_2; outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); @@ -773,7 +773,7 @@ static int apci3120_cyclic_ai(int mode, apci3120_timer_write(dev, 1, divisor1); /* init timer0 in mode 2 */ - devpriv->timer_mode &= 0xfc; + devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(0); devpriv->timer_mode |= APCI3120_TIMER_0_MODE_2; outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); @@ -824,7 +824,7 @@ static int apci3120_cyclic_ai(int mode, dev->iobase + APCI3120_WRITE_MODE_SELECT); /* (1) Init timer 2 in mode 0 and write timer value */ - devpriv->timer_mode &= 0x0f; + devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(2); devpriv->timer_mode |= APCI3120_TIMER_2_MODE_0; outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); @@ -1422,7 +1422,7 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, dev->iobase + APCI3120_WRITE_MODE_SELECT); if (data[0] == APCI3120_TIMER) { /* initialize timer */ /* Set the Timer 2 in mode 2(Timer) */ - devpriv->timer_mode &= 0x0f; + devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(2); devpriv->timer_mode |= APCI3120_TIMER_2_MODE_2; outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); @@ -1435,7 +1435,7 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, } else { /* Initialize Watch dog */ /* Set the Timer 2 in mode 5(Watchdog) */ - devpriv->timer_mode &= 0x0f; + devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(2); devpriv->timer_mode |= APCI3120_TIMER_2_MODE_5; outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_CRT1); diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 6882f8ee67a4..999add3928ef 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -20,6 +20,7 @@ #define APCI3120_AO_REG(x) (0x08 + (((x) / 4) * 2)) #define APCI3120_AO_MUX(x) (((x) & 0x3) << 14) #define APCI3120_AO_DATA(x) ((x) << 0) +#define APCI3120_TIMER_MODE_MASK(_t) (3 << ((_t) * 2)) #define APCI3120_CTR0_REG 0x0d #define APCI3120_CTR0_DO_BITS(x) ((x) << 4) #define APCI3120_CTR0_TIMER_SEL(x) ((x) << 0)