From: H Hartley Sweeten Date: Tue, 4 Nov 2014 17:53:55 +0000 (-0700) Subject: staging: comedi: addi_apci_3120: move timer helpers to main driver source X-Git-Tag: v3.19-rc1~66^2~344 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=b3c8ee5cbc5f995c738a5651a2b22297950be6a2;p=karo-tx-linux.git staging: comedi: addi_apci_3120: move timer helpers to main driver source Move the timer read/write and set mode helpers from the included source file into the main driver source file. 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 dc6eb56e0e1a..d4d66e490b54 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -171,59 +171,6 @@ static const struct comedi_lrange range_apci3120_ai = { } }; -static void apci3120_timer_write(struct comedi_device *dev, - unsigned int timer, unsigned int val) -{ - struct apci3120_private *devpriv = dev->private; - - /* write 16-bit value to timer (lower 16-bits of timer 2) */ - outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) | - APCI3120_CTR0_TIMER_SEL(timer), - dev->iobase + APCI3120_CTR0_REG); - outw(val & 0xffff, dev->iobase + APCI3120_TIMER_REG); - - if (timer == 2) { - /* write upper 16-bits to timer 2 */ - outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) | - APCI3120_CTR0_TIMER_SEL(timer + 1), - dev->iobase + APCI3120_CTR0_REG); - outw((val >> 16) & 0xffff, dev->iobase + APCI3120_TIMER_REG); - } -} - -static unsigned int apci3120_timer_read(struct comedi_device *dev, - unsigned int timer) -{ - struct apci3120_private *devpriv = dev->private; - unsigned int val; - - /* read 16-bit value from timer (lower 16-bits of timer 2) */ - outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) | - APCI3120_CTR0_TIMER_SEL(timer), - dev->iobase + APCI3120_CTR0_REG); - val = inw(dev->iobase + APCI3120_TIMER_REG); - - if (timer == 2) { - /* read upper 16-bits from timer 2 */ - outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) | - APCI3120_CTR0_TIMER_SEL(timer + 1), - dev->iobase + APCI3120_CTR0_REG); - val |= (inw(dev->iobase + APCI3120_TIMER_REG) << 16); - } - - return val; -} - -static void apci3120_timer_set_mode(struct comedi_device *dev, - unsigned int timer, unsigned int mode) -{ - struct apci3120_private *devpriv = dev->private; - - devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(timer); - devpriv->timer_mode |= APCI3120_TIMER_MODE(timer, mode); - outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_MODE_REG); -} - static int apci3120_ai_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 20babacd40d3..e53561194bae 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -150,6 +150,59 @@ static unsigned int apci3120_ns_to_timer(struct comedi_device *dev, return divisor; } +static void apci3120_timer_write(struct comedi_device *dev, + unsigned int timer, unsigned int val) +{ + struct apci3120_private *devpriv = dev->private; + + /* write 16-bit value to timer (lower 16-bits of timer 2) */ + outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) | + APCI3120_CTR0_TIMER_SEL(timer), + dev->iobase + APCI3120_CTR0_REG); + outw(val & 0xffff, dev->iobase + APCI3120_TIMER_REG); + + if (timer == 2) { + /* write upper 16-bits to timer 2 */ + outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) | + APCI3120_CTR0_TIMER_SEL(timer + 1), + dev->iobase + APCI3120_CTR0_REG); + outw((val >> 16) & 0xffff, dev->iobase + APCI3120_TIMER_REG); + } +} + +static unsigned int apci3120_timer_read(struct comedi_device *dev, + unsigned int timer) +{ + struct apci3120_private *devpriv = dev->private; + unsigned int val; + + /* read 16-bit value from timer (lower 16-bits of timer 2) */ + outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) | + APCI3120_CTR0_TIMER_SEL(timer), + dev->iobase + APCI3120_CTR0_REG); + val = inw(dev->iobase + APCI3120_TIMER_REG); + + if (timer == 2) { + /* read upper 16-bits from timer 2 */ + outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) | + APCI3120_CTR0_TIMER_SEL(timer + 1), + dev->iobase + APCI3120_CTR0_REG); + val |= (inw(dev->iobase + APCI3120_TIMER_REG) << 16); + } + + return val; +} + +static void apci3120_timer_set_mode(struct comedi_device *dev, + unsigned int timer, unsigned int mode) +{ + struct apci3120_private *devpriv = dev->private; + + devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(timer); + devpriv->timer_mode |= APCI3120_TIMER_MODE(timer, mode); + outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_MODE_REG); +} + #include "addi-data/hwdrv_apci3120.c" static void apci3120_dma_alloc(struct comedi_device *dev)