[PATCH 14/18] staging: comedi: s526: tidy up s526_ai_rinsn()

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

 



Rename this function to follow the normal naming in comedi drivers.

Use the comedi_offset_munge() helper to munge the hardware two's
complement data to the comedi offset binary format.

Change the final return to insn->n to clarify the return value without
the need for the comment.

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

diff --git a/drivers/staging/comedi/drivers/s526.c b/drivers/staging/comedi/drivers/s526.c
index 152be95..1a5aa3d 100644
--- a/drivers/staging/comedi/drivers/s526.c
+++ b/drivers/staging/comedi/drivers/s526.c
@@ -434,15 +434,17 @@ static int s526_eoc(struct comedi_device *dev,
 	return -EBUSY;
 }
 
-static int s526_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
-			 struct comedi_insn *insn, unsigned int *data)
+static int s526_ai_insn_read(struct comedi_device *dev,
+			     struct comedi_subdevice *s,
+			     struct comedi_insn *insn,
+			     unsigned int *data)
 {
 	struct s526_private *devpriv = dev->private;
 	unsigned int chan = CR_CHAN(insn->chanspec);
 	unsigned int ctrl;
-	int n;
-	unsigned int d;
+	unsigned int val;
 	int ret;
+	int i;
 
 	/*
 	 * Set configured delay, enable conversion and read for requested
@@ -452,8 +454,7 @@ static int s526_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
 	       S526_AI_CTRL_CONV(chan) | S526_AI_CTRL_READ(chan) |
 	       S526_AI_CTRL_START;
 
-	/* convert n samples */
-	for (n = 0; n < insn->n; n++) {
+	for (i = 0; i < insn->n; i++) {
 		/* trigger conversion */
 		outw(ctrl, dev->iobase + S526_AI_CTRL_REG);
 
@@ -462,14 +463,11 @@ static int s526_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
 		if (ret)
 			return ret;
 
-		d = inw(dev->iobase + S526_AI_REG);
-
-		/* munge data */
-		data[n] = d ^ 0x8000;
+		val = inw(dev->iobase + S526_AI_REG);
+		data[i] = comedi_offset_munge(s, val);
 	}
 
-	/* return the number of samples read/written */
-	return n;
+	return insn->n;
 }
 
 static int s526_ao_insn_write(struct comedi_device *dev,
@@ -591,7 +589,7 @@ static int s526_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	s->maxdata	= 0xffff;
 	s->range_table	= &range_bipolar10;
 	s->len_chanlist	= 16;
-	s->insn_read	= s526_ai_rinsn;
+	s->insn_read	= s526_ai_insn_read;
 	s->insn_config	= s526_ai_insn_config;
 
 	/* Analog Output subdevice */
-- 
2.4.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