From 0e771e49fc2174054bbb4927f9afe8db4e16ae0b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 12 Jun 2013 16:15:07 -0700 Subject: [PATCH] staging: comedi: addi_apci_3xxx: absorb i_APCI3XXX_InsnWriteAnalogOutput() Rename this CamelCase function and absorb it from hwdrv_apci3xxx.c directly into the driver. Tidy up the analog output subdevice init by adding some whitespace. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci3xxx.c | 27 ------------ .../staging/comedi/drivers/addi_apci_3xxx.c | 43 +++++++++++++++---- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c index 7575464c7f32..dc4b16544848 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3xxx.c @@ -515,33 +515,6 @@ static int i_APCI3XXX_InsnReadAnalogInput(struct comedi_device *dev, return i_ReturnValue; } -static int i_APCI3XXX_InsnWriteAnalogOutput(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci3xxx_private *devpriv = dev->private; - unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int range = CR_RANGE(insn->chanspec); - unsigned int status; - int i; - - for (i = 0; i < insn->n; i++) { - /* Set the range selection */ - writel(range, devpriv->dw_AiBase + 96); - - /* Write the analog value to the selected channel */ - writel((data[i] << 8) | chan, devpriv->dw_AiBase + 100); - - /* Wait the end of transfer */ - do { - status = readl(devpriv->dw_AiBase + 96); - } while ((status & 0x100) != 0x100); - } - - return insn->n; -} - /* +----------------------------------------------------------------------------+ | TTL FUNCTIONS | diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c index 8453dfe2d739..c3dfe5188e7a 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c @@ -416,6 +416,33 @@ static irqreturn_t apci3xxx_irq_handler(int irq, void *d) return IRQ_RETVAL(1); } +static int apci3xxx_ao_insn_write(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + struct apci3xxx_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int range = CR_RANGE(insn->chanspec); + unsigned int status; + int i; + + for (i = 0; i < insn->n; i++) { + /* Set the range selection */ + writel(range, devpriv->dw_AiBase + 96); + + /* Write the analog value to the selected channel */ + writel((data[i] << 8) | chan, devpriv->dw_AiBase + 100); + + /* Wait the end of transfer */ + do { + status = readl(devpriv->dw_AiBase + 96); + } while ((status & 0x100) != 0x100); + } + + return insn->n; +} + static int apci3xxx_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -553,17 +580,17 @@ static int apci3xxx_auto_attach(struct comedi_device *dev, s->type = COMEDI_SUBD_UNUSED; } - /* Allocate and Initialise AO Subdevice Structures */ + /* Analog Output subdevice */ s = &dev->subdevices[1]; if (board->has_ao) { - s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = 4; - s->maxdata = 0x0fff; - s->range_table = &apci3xxx_ao_range; - s->insn_write = i_APCI3XXX_InsnWriteAnalogOutput; + s->type = COMEDI_SUBD_AO; + s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; + s->n_chan = 4; + s->maxdata = 0x0fff; + s->range_table = &apci3xxx_ao_range; + s->insn_write = apci3xxx_ao_insn_write; } else { - s->type = COMEDI_SUBD_UNUSED; + s->type = COMEDI_SUBD_UNUSED; } /* Digital Input subdevice */ -- 2.34.1