From 649a7d15d3ec3bc5327b8910946e2119e92425e8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 5 Sep 2014 09:25:51 -0700 Subject: [PATCH] staging: comedi: adl_pci9118: move analog input (*insn_read) function 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 Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 123 ++++++++++--------- 1 file changed, 62 insertions(+), 61 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 1fb63706bda8..41fa6152b74c 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -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; -- 2.30.2