[RFC PATCH 26/30] staging: comedi: dt9812: cleanup analog out subdevice (*insn_read)

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

 



For aesthetic reasons, rename the function to help with grepping and
rename some of the local vars.

This function returns the current analog output value for the channel
that is cached in the private data. Absorb dt9812_analog_out_shadow()
into this function to make it more concise.

The comedi core expects the (*insn_read) functions to return either
an errno or the number of samples read. Change the final return to
insn->n to make this clearer.

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

diff --git a/drivers/staging/comedi/drivers/dt9812.c b/drivers/staging/comedi/drivers/dt9812.c
index cd0966f..aa478bb 100644
--- a/drivers/staging/comedi/drivers/dt9812.c
+++ b/drivers/staging/comedi/drivers/dt9812.c
@@ -529,18 +529,6 @@ exit:
 	return ret;
 }
 
-static int dt9812_analog_out_shadow(struct comedi_device *dev,
-				    int channel, u16 *value)
-{
-	struct dt9812_private *devpriv = dev->private;
-
-	down(&devpriv->sem);
-	*value = devpriv->ao_shadow[channel];
-	up(&devpriv->sem);
-
-	return 0;
-}
-
 static int dt9812_analog_out(struct comedi_device *dev, int channel, u16 value)
 {
 	struct dt9812_private *devpriv = dev->private;
@@ -651,20 +639,21 @@ static int dt9812_ai_insn_read(struct comedi_device *dev,
 	return insn->n;
 }
 
-static int dt9812_ao_rinsn(struct comedi_device *dev,
-			   struct comedi_subdevice *s, struct comedi_insn *insn,
-			   unsigned int *data)
+static int dt9812_ao_insn_read(struct comedi_device *dev,
+			       struct comedi_subdevice *s,
+			       struct comedi_insn *insn,
+			       unsigned int *data)
 {
-	unsigned int channel = CR_CHAN(insn->chanspec);
-	int n;
-	u16 value;
+	struct dt9812_private *devpriv = dev->private;
+	unsigned int chan = CR_CHAN(insn->chanspec);
+	int i;
 
-	for (n = 0; n < insn->n; n++) {
-		value = 0;
-		dt9812_analog_out_shadow(dev, channel, &value);
-		data[n] = value;
-	}
-	return n;
+	down(&devpriv->sem);
+	for (i = 0; i < insn->n; i++)
+		data[i] = devpriv->ao_shadow[chan];
+	up(&devpriv->sem);
+
+	return insn->n;
 }
 
 static int dt9812_ao_winsn(struct comedi_device *dev,
@@ -859,7 +848,7 @@ static int dt9812_auto_attach(struct comedi_device *dev,
 	s->maxdata	= 0x0fff;
 	s->range_table	= is_unipolar ? &range_unipolar2_5 : &range_bipolar10;
 	s->insn_write	= dt9812_ao_winsn;
-	s->insn_read	= dt9812_ao_rinsn;
+	s->insn_read	= dt9812_ao_insn_read;
 
 	devpriv->ao_shadow[0] = is_unipolar ? 0x0000 : 0x0800;
 	devpriv->ao_shadow[1] = is_unipolar ? 0x0000 : 0x0800;
-- 
1.8.1.4

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/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