[PATCH 20/30] staging: comedi: adl_pci9118: absorb pci9118_ai_set_range_aref()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This function is called by the analog input (*insn_read) and (*do_cmd)
operations. The pci9118_set_chanlist() function is also called by those
operations. Setting the range and aref logically belongs with setting
the chanlist. To clarify the code, absorb pci9118_ai_set_range_aref()
into pci9118_set_chanlist().

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 drivers/staging/comedi/drivers/adl_pci9118.c | 41 +++++++++++-----------------
 1 file changed, 16 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c
index 89a6ea5..8820eea 100644
--- a/drivers/staging/comedi/drivers/adl_pci9118.c
+++ b/drivers/staging/comedi/drivers/adl_pci9118.c
@@ -322,22 +322,6 @@ static void pci9118_ai_reset_fifo(struct comedi_device *dev)
 	outl(0, dev->iobase + PCI9118_FIFO_RESET_REG);
 }
 
-static void pci9118_ai_set_range_aref(struct comedi_device *dev,
-				      struct comedi_subdevice *s,
-				      unsigned int chanspec)
-{
-	struct pci9118_private *devpriv = dev->private;
-	unsigned int range = CR_RANGE(chanspec);
-	unsigned int aref = CR_AREF(chanspec);
-
-	devpriv->ai_ctrl = 0;
-	if (comedi_range_is_unipolar(s, range))
-		devpriv->ai_ctrl |= PCI9118_AI_CTRL_UNIP;
-	if (aref == AREF_DIFF)
-		devpriv->ai_ctrl |= PCI9118_AI_CTRL_DIFF;
-	outl(devpriv->ai_ctrl, dev->iobase + PCI9118_AI_CTRL_REG);
-}
-
 static int check_channel_list(struct comedi_device *dev,
 			      struct comedi_subdevice *s, int n_chan,
 			      unsigned int *chanlist, int frontadd, int backadd)
@@ -391,9 +375,23 @@ static void pci9118_set_chanlist(struct comedi_device *dev,
 				 int frontadd, int backadd)
 {
 	struct pci9118_private *devpriv = dev->private;
+	unsigned int range0 = CR_RANGE(chanlist[0]);
+	unsigned int aref0 = CR_AREF(chanlist[0]);
 	unsigned int scanquad, gain, ssh = 0x00;
 	int i;
 
+	/*
+	 * Configure analog input based on the first chanlist entry.
+	 * All entries are either unipolar or bipolar and single-ended
+	 * or differential.
+	 */
+	devpriv->ai_ctrl = 0;
+	if (comedi_range_is_unipolar(s, range0))
+		devpriv->ai_ctrl |= PCI9118_AI_CTRL_UNIP;
+	if (aref0 == AREF_DIFF)
+		devpriv->ai_ctrl |= PCI9118_AI_CTRL_DIFF;
+	outl(devpriv->ai_ctrl, dev->iobase + PCI9118_AI_CTRL_REG);
+
 	/* gods know why this sequence! */
 	outl(2, dev->iobase + PCI9118_AI_AUTOSCAN_MODE_REG);
 	outl(0, dev->iobase + PCI9118_AI_AUTOSCAN_MODE_REG);
@@ -1327,14 +1325,9 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 		return -EINVAL;
 
 	/*
-	 * Configure analog input based on the first chanlist entry.
-	 * All entries are either unipolar or bipolar and single-ended
-	 * or differential.
-	 *
+	 * Configure analog input and load the chanlist.
 	 * The acqusition control bits are enabled later.
 	 */
-	pci9118_ai_set_range_aref(dev, s, cmd->chanlist[0]);
-
 	pci9118_set_chanlist(dev, s, cmd->chanlist_len, cmd->chanlist,
 			     devpriv->ai_add_front, devpriv->ai_add_back);
 
@@ -1443,14 +1436,12 @@ static int pci9118_ai_insn_read(struct comedi_device *dev,
 	* Configure analog input based on the chanspec.
 	* Acqusition is software controlled without interrupts.
 	*/
-	pci9118_ai_set_range_aref(dev, s, insn->chanspec);
+	pci9118_set_chanlist(dev, s, 1, &insn->chanspec, 0, 0);
 
 	/* 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);
 
-	pci9118_set_chanlist(dev, s, 1, &insn->chanspec, 0, 0);
-
 	pci9118_ai_reset_fifo(dev);
 
 	for (i = 0; i < insn->n; i++) {
-- 
2.0.3

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux