Commit bf483f1e authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: s526: tidy up s526_ai_rinsn()

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: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 09c5d6c8
...@@ -434,15 +434,17 @@ static int s526_eoc(struct comedi_device *dev, ...@@ -434,15 +434,17 @@ static int s526_eoc(struct comedi_device *dev,
return -EBUSY; return -EBUSY;
} }
static int s526_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, static int s526_ai_insn_read(struct comedi_device *dev,
struct comedi_insn *insn, unsigned int *data) struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{ {
struct s526_private *devpriv = dev->private; struct s526_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(insn->chanspec); unsigned int chan = CR_CHAN(insn->chanspec);
unsigned int ctrl; unsigned int ctrl;
int n; unsigned int val;
unsigned int d;
int ret; int ret;
int i;
/* /*
* Set configured delay, enable conversion and read for requested * 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, ...@@ -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_CONV(chan) | S526_AI_CTRL_READ(chan) |
S526_AI_CTRL_START; S526_AI_CTRL_START;
/* convert n samples */ for (i = 0; i < insn->n; i++) {
for (n = 0; n < insn->n; n++) {
/* trigger conversion */ /* trigger conversion */
outw(ctrl, dev->iobase + S526_AI_CTRL_REG); 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, ...@@ -462,14 +463,11 @@ static int s526_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
if (ret) if (ret)
return ret; return ret;
d = inw(dev->iobase + S526_AI_REG); val = inw(dev->iobase + S526_AI_REG);
data[i] = comedi_offset_munge(s, val);
/* munge data */
data[n] = d ^ 0x8000;
} }
/* return the number of samples read/written */ return insn->n;
return n;
} }
static int s526_ao_insn_write(struct comedi_device *dev, 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) ...@@ -591,7 +589,7 @@ static int s526_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s->maxdata = 0xffff; s->maxdata = 0xffff;
s->range_table = &range_bipolar10; s->range_table = &range_bipolar10;
s->len_chanlist = 16; s->len_chanlist = 16;
s->insn_read = s526_ai_rinsn; s->insn_read = s526_ai_insn_read;
s->insn_config = s526_ai_insn_config; s->insn_config = s526_ai_insn_config;
/* Analog Output subdevice */ /* Analog Output subdevice */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment