From: H Hartley Sweeten Date: Fri, 22 Mar 2013 16:37:37 +0000 (-0700) Subject: staging: comedi: ni_labpc: move the analog output support functions X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=8913491d9040f02b46f8766eacab5935a7fb9106;p=openwrt%2Fstaging%2Fblogic.git staging: comedi: ni_labpc: move the analog output support functions For aesthetic reasons, move the analog output support functions. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Cc: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index 198198a7091d..b470afc5701d 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -1310,60 +1310,6 @@ static int labpc_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, return n; } -/* analog output insn */ -static int labpc_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - const struct labpc_boardinfo *thisboard = comedi_board(dev); - struct labpc_private *devpriv = dev->private; - int channel, range; - unsigned long flags; - int lsb, msb; - - channel = CR_CHAN(insn->chanspec); - - /* turn off pacing of analog output channel */ - /* note: hardware bug in daqcard-1200 means pacing cannot - * be independently enabled/disabled for its the two channels */ - spin_lock_irqsave(&dev->spinlock, flags); - devpriv->command2_bits &= ~DAC_PACED_BIT(channel); - devpriv->write_byte(devpriv->command2_bits, dev->iobase + COMMAND2_REG); - spin_unlock_irqrestore(&dev->spinlock, flags); - - /* set range */ - if (thisboard->register_layout == labpc_1200_layout) { - range = CR_RANGE(insn->chanspec); - if (range & AO_RANGE_IS_UNIPOLAR) - devpriv->command6_bits |= DAC_UNIP_BIT(channel); - else - devpriv->command6_bits &= ~DAC_UNIP_BIT(channel); - /* write to register */ - devpriv->write_byte(devpriv->command6_bits, - dev->iobase + COMMAND6_REG); - } - /* send data */ - lsb = data[0] & 0xff; - msb = (data[0] >> 8) & 0xff; - devpriv->write_byte(lsb, dev->iobase + DAC_LSB_REG(channel)); - devpriv->write_byte(msb, dev->iobase + DAC_MSB_REG(channel)); - - /* remember value for readback */ - devpriv->ao_value[channel] = data[0]; - - return 1; -} - -/* analog output readback insn */ -static int labpc_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - struct labpc_private *devpriv = dev->private; - - data[0] = devpriv->ao_value[CR_CHAN(insn->chanspec)]; - - return 1; -} - #ifdef CONFIG_ISA_DMA_API /* utility function that suggests a dma transfer size in bytes */ static unsigned int labpc_suggest_transfer_size(const struct comedi_cmd *cmd) @@ -1486,6 +1432,60 @@ static void labpc_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd, } } +/* analog output insn */ +static int labpc_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) +{ + const struct labpc_boardinfo *thisboard = comedi_board(dev); + struct labpc_private *devpriv = dev->private; + int channel, range; + unsigned long flags; + int lsb, msb; + + channel = CR_CHAN(insn->chanspec); + + /* turn off pacing of analog output channel */ + /* note: hardware bug in daqcard-1200 means pacing cannot + * be independently enabled/disabled for its the two channels */ + spin_lock_irqsave(&dev->spinlock, flags); + devpriv->command2_bits &= ~DAC_PACED_BIT(channel); + devpriv->write_byte(devpriv->command2_bits, dev->iobase + COMMAND2_REG); + spin_unlock_irqrestore(&dev->spinlock, flags); + + /* set range */ + if (thisboard->register_layout == labpc_1200_layout) { + range = CR_RANGE(insn->chanspec); + if (range & AO_RANGE_IS_UNIPOLAR) + devpriv->command6_bits |= DAC_UNIP_BIT(channel); + else + devpriv->command6_bits &= ~DAC_UNIP_BIT(channel); + /* write to register */ + devpriv->write_byte(devpriv->command6_bits, + dev->iobase + COMMAND6_REG); + } + /* send data */ + lsb = data[0] & 0xff; + msb = (data[0] >> 8) & 0xff; + devpriv->write_byte(lsb, dev->iobase + DAC_LSB_REG(channel)); + devpriv->write_byte(msb, dev->iobase + DAC_MSB_REG(channel)); + + /* remember value for readback */ + devpriv->ao_value[channel] = data[0]; + + return 1; +} + +/* analog output readback insn */ +static int labpc_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) +{ + struct labpc_private *devpriv = dev->private; + + data[0] = devpriv->ao_value[CR_CHAN(insn->chanspec)]; + + return 1; +} + static int labpc_dio_mem_callback(int dir, int port, int data, unsigned long iobase) {