diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2013-03-22 09:49:10 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-03-25 11:42:58 -0700 |
commit | 8a498667b613387ee270bc0b49a375294e38a4f6 (patch) | |
tree | 895bccccf2a580e255350dc7b38100fa7219097c /drivers | |
parent | 8c2bc333af026bed05a0041b028c34ef9b5c9cab (diff) |
staging: comedi: ni_labpc:use labpc_cancel() to remove some common code
The labpc_cancel() function can be used by the labpc_ai_insn_read() and
labpc_ai_cmd() functions to disable the ai subdevice.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/comedi/drivers/ni_labpc.c | 52 |
1 files changed, 19 insertions, 33 deletions
diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index dbc358970171..2b9bd61943af 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -354,6 +354,22 @@ static bool labpc_range_is_unipolar(struct comedi_subdevice *s, return true; } +static int labpc_cancel(struct comedi_device *dev, struct comedi_subdevice *s) +{ + struct labpc_private *devpriv = dev->private; + unsigned long flags; + + spin_lock_irqsave(&dev->spinlock, flags); + devpriv->cmd2 &= ~SWTRIG_BIT & ~HWTRIG_BIT & ~PRETRIG_BIT; + devpriv->write_byte(devpriv->cmd2, dev->iobase + COMMAND2_REG); + spin_unlock_irqrestore(&dev->spinlock, flags); + + devpriv->cmd3 = 0; + devpriv->write_byte(devpriv->cmd3, dev->iobase + COMMAND3_REG); + + return 0; +} + static void labpc_ai_set_chan_and_gain(struct comedi_device *dev, enum scan_mode mode, unsigned int chan, @@ -393,19 +409,11 @@ static int labpc_ai_insn_read(struct comedi_device *dev, unsigned int range = CR_RANGE(insn->chanspec); unsigned int aref = CR_AREF(insn->chanspec); int timeout = 1000; - unsigned long flags; int lsb, msb; int i, n; - /* disable timed conversions */ - spin_lock_irqsave(&dev->spinlock, flags); - devpriv->cmd2 &= ~SWTRIG_BIT & ~HWTRIG_BIT & ~PRETRIG_BIT; - devpriv->write_byte(devpriv->cmd2, dev->iobase + COMMAND2_REG); - spin_unlock_irqrestore(&dev->spinlock, flags); - - /* disable interrupt generation and dma */ - devpriv->cmd3 = 0; - devpriv->write_byte(devpriv->cmd3, dev->iobase + COMMAND3_REG); + /* disable timed conversions, interrupt generation and dma */ + labpc_cancel(dev, s); labpc_ai_set_chan_and_gain(dev, MODE_SINGLE_CHAN, chan, range, aref); @@ -876,13 +884,7 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) int ret; /* make sure board is disabled before setting up acquisition */ - spin_lock_irqsave(&dev->spinlock, flags); - devpriv->cmd2 &= ~SWTRIG_BIT & ~HWTRIG_BIT & ~PRETRIG_BIT; - devpriv->write_byte(devpriv->cmd2, dev->iobase + COMMAND2_REG); - spin_unlock_irqrestore(&dev->spinlock, flags); - - devpriv->cmd3 = 0; - devpriv->write_byte(devpriv->cmd3, dev->iobase + COMMAND3_REG); + labpc_cancel(dev, s); /* initialize software conversion count */ if (cmd->stop_src == TRIG_COUNT) @@ -1109,22 +1111,6 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) return 0; } -static int labpc_cancel(struct comedi_device *dev, struct comedi_subdevice *s) -{ - struct labpc_private *devpriv = dev->private; - unsigned long flags; - - spin_lock_irqsave(&dev->spinlock, flags); - devpriv->cmd2 &= ~SWTRIG_BIT & ~HWTRIG_BIT & ~PRETRIG_BIT; - devpriv->write_byte(devpriv->cmd2, dev->iobase + COMMAND2_REG); - spin_unlock_irqrestore(&dev->spinlock, flags); - - devpriv->cmd3 = 0; - devpriv->write_byte(devpriv->cmd3, dev->iobase + COMMAND3_REG); - - return 0; -} - #ifdef CONFIG_ISA_DMA_API static void labpc_drain_dma(struct comedi_device *dev) { |