staging: comedi: adl_pci9118: move analog input (*insn_read) function
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Fri, 5 Sep 2014 16:25:51 +0000 (09:25 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 8 Sep 2014 20:56:08 +0000 (13:56 -0700)
For aesthetics, move the analog input (*insn_read) function so it
is not located in the middle of the async command support functions.
Also, rename it for consistency.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/adl_pci9118.c

index 1fb63706bda8d39c64043fd91acf3ad17b269010..41fa6152b74c4017a9442d58106857c3bd31cb8b 100644 (file)
@@ -489,66 +489,6 @@ static int setup_channel_list(struct comedi_device *dev,
        return 1;               /* we can serve this with scan logic */
 }
 
-static int pci9118_ai_eoc(struct comedi_device *dev,
-                         struct comedi_subdevice *s,
-                         struct comedi_insn *insn,
-                         unsigned long context)
-{
-       unsigned int status;
-
-       status = inl(dev->iobase + PCI9118_AI_STATUS_REG);
-       if (status & PCI9118_AI_STATUS_ADRDY)
-               return 0;
-       return -EBUSY;
-}
-
-static void pci9118_ai_start_conv(struct comedi_device *dev)
-{
-       /* writing any value triggers an A/D conversion */
-       outl(0, dev->iobase + PCI9118_SOFTTRG_REG);
-}
-
-static int pci9118_insn_read_ai(struct comedi_device *dev,
-                               struct comedi_subdevice *s,
-                               struct comedi_insn *insn, unsigned int *data)
-{
-       struct pci9118_private *devpriv = dev->private;
-       unsigned int val;
-       int ret;
-       int n;
-
-       /*
-       * Configure analog input based on the chanspec.
-       * Acqusition is software controlled without interrupts.
-       */
-       pci9118_ai_set_range_aref(dev, s, insn->chanspec);
-
-       /* set default config (disable burst and triggers) */
-       devpriv->ai_cfg = PCI9118_AI_CFG_PDTRG | PCI9118_AI_CFG_PETRG;
-       outl(devpriv->ai_cfg, dev->iobase + PCI9118_AI_CFG_REG);
-
-       if (!setup_channel_list(dev, s, 1, &insn->chanspec, 0, 0, 0, 0))
-               return -EINVAL;
-
-       pci9118_ai_reset_fifo(dev);
-
-       for (n = 0; n < insn->n; n++) {
-               pci9118_ai_start_conv(dev);
-
-               ret = comedi_timeout(dev, s, insn, pci9118_ai_eoc, 0);
-               if (ret)
-                       return ret;
-
-               val = inl(dev->iobase + PCI9118_AI_FIFO_REG);
-               if (s->maxdata == 0xffff)
-                       data[n] = (val & 0xffff) ^ 0x8000;
-               else
-                       data[n] = (val >> 4) & 0xfff;
-       }
-
-       return n;
-}
-
 static void interrupt_pci9118_ai_mode4_switch(struct comedi_device *dev)
 {
        struct pci9118_private *devpriv = dev->private;
@@ -1600,6 +1540,67 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
        return ret;
 }
 
+static int pci9118_ai_eoc(struct comedi_device *dev,
+                         struct comedi_subdevice *s,
+                         struct comedi_insn *insn,
+                         unsigned long context)
+{
+       unsigned int status;
+
+       status = inl(dev->iobase + PCI9118_AI_STATUS_REG);
+       if (status & PCI9118_AI_STATUS_ADRDY)
+               return 0;
+       return -EBUSY;
+}
+
+static void pci9118_ai_start_conv(struct comedi_device *dev)
+{
+       /* writing any value triggers an A/D conversion */
+       outl(0, dev->iobase + PCI9118_SOFTTRG_REG);
+}
+
+static int pci9118_ai_insn_read(struct comedi_device *dev,
+                               struct comedi_subdevice *s,
+                               struct comedi_insn *insn,
+                               unsigned int *data)
+{
+       struct pci9118_private *devpriv = dev->private;
+       unsigned int val;
+       int ret;
+       int i;
+
+       /*
+       * Configure analog input based on the chanspec.
+       * Acqusition is software controlled without interrupts.
+       */
+       pci9118_ai_set_range_aref(dev, s, insn->chanspec);
+
+       /* set default config (disable burst and triggers) */
+       devpriv->ai_cfg = PCI9118_AI_CFG_PDTRG | PCI9118_AI_CFG_PETRG;
+       outl(devpriv->ai_cfg, dev->iobase + PCI9118_AI_CFG_REG);
+
+       if (!setup_channel_list(dev, s, 1, &insn->chanspec, 0, 0, 0, 0))
+               return -EINVAL;
+
+       pci9118_ai_reset_fifo(dev);
+
+       for (i = 0; i < insn->n; i++) {
+               pci9118_ai_start_conv(dev);
+
+               ret = comedi_timeout(dev, s, insn, pci9118_ai_eoc, 0);
+               if (ret)
+                       return ret;
+
+               val = inl(dev->iobase + PCI9118_AI_FIFO_REG);
+               if (s->maxdata == 0xffff)
+                       data[i] = (val & 0xffff) ^ 0x8000;
+               else
+                       data[i] = (val >> 4) & 0xfff;
+       }
+
+       return insn->n;
+}
+
 static int pci9118_ao_insn_write(struct comedi_device *dev,
                                 struct comedi_subdevice *s,
                                 struct comedi_insn *insn,
@@ -1803,7 +1804,7 @@ static int pci9118_common_attach(struct comedi_device *dev, int disable_irq,
        s->maxdata      = board->ai_is_16bit ? 0xffff : 0x0fff;
        s->range_table  = board->is_hg ? &pci9118hg_ai_range
                                       : &pci9118_ai_range;
-       s->insn_read    = pci9118_insn_read_ai;
+       s->insn_read    = pci9118_ai_insn_read;
        if (dev->irq) {
                dev->read_subdev = s;
                s->subdev_flags |= SDF_CMD_READ;
This page took 0.026596 seconds and 5 git commands to generate.