Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d8dc10bf authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman
Browse files

staging: comedi: adq12b: tidy up adq12b_ai_rinsn()



For aesthetics, rename this function.

Clean up the local variables by reusing 'val' instead of using
separate variables for the:
  'status' - use once to trigger the first A/D conversion
  'hi' and 'lo' - used to read the A/D conversion result

For aesthetics, change the final return to insn->n and remove 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 f93b399b
Loading
Loading
Loading
Loading
+12 −20
Original line number Original line Diff line number Diff line
@@ -132,7 +132,7 @@ static int adq12b_ai_eoc(struct comedi_device *dev,
	return -EBUSY;
	return -EBUSY;
}
}


static int adq12b_ai_rinsn(struct comedi_device *dev,
static int adq12b_ai_insn_read(struct comedi_device *dev,
			       struct comedi_subdevice *s,
			       struct comedi_subdevice *s,
			       struct comedi_insn *insn,
			       struct comedi_insn *insn,
			       unsigned int *data)
			       unsigned int *data)
@@ -141,9 +141,8 @@ static int adq12b_ai_rinsn(struct comedi_device *dev,
	unsigned int chan = CR_CHAN(insn->chanspec);
	unsigned int chan = CR_CHAN(insn->chanspec);
	unsigned int range = CR_RANGE(insn->chanspec);
	unsigned int range = CR_RANGE(insn->chanspec);
	unsigned int val;
	unsigned int val;
	int n;
	unsigned char hi, lo, status;
	int ret;
	int ret;
	int i;


	/* change channel and range only if it is different from the previous */
	/* change channel and range only if it is different from the previous */
	val = (range << 4) | chan;
	val = (range << 4) | chan;
@@ -153,27 +152,20 @@ static int adq12b_ai_rinsn(struct comedi_device *dev,
		udelay(50);	/* wait for the mux to settle */
		udelay(50);	/* wait for the mux to settle */
	}
	}


	/* trigger conversion */
	val = inb(dev->iobase + ADQ12B_ADLOW);	/* trigger A/D */
	status = inb(dev->iobase + ADQ12B_ADLOW);


	/* convert n samples */
	for (i = 0; i < insn->n; i++) {
	for (n = 0; n < insn->n; n++) {

		/* wait for end of conversion */
		ret = comedi_timeout(dev, s, insn, adq12b_ai_eoc, 0);
		ret = comedi_timeout(dev, s, insn, adq12b_ai_eoc, 0);
		if (ret)
		if (ret)
			return ret;
			return ret;


		/* read data */
		val = inb(dev->iobase + ADQ12B_ADHIG) << 8;
		hi = inb(dev->iobase + ADQ12B_ADHIG);
		val |= inb(dev->iobase + ADQ12B_ADLOW);	/* retriggers A/D */
		lo = inb(dev->iobase + ADQ12B_ADLOW);

		data[n] = (hi << 8) | lo;


		data[i] = val;
	}
	}


	/* return the number of samples read/written */
	return insn->n;
	return n;
}
}


static int adq12b_di_insn_bits(struct comedi_device *dev,
static int adq12b_di_insn_bits(struct comedi_device *dev,
@@ -254,7 +246,7 @@ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it)


	s->len_chanlist = 4;	/* This is the maximum chanlist length that
	s->len_chanlist = 4;	/* This is the maximum chanlist length that
				   the board can handle */
				   the board can handle */
	s->insn_read = adq12b_ai_rinsn;
	s->insn_read = adq12b_ai_insn_read;


	s = &dev->subdevices[1];
	s = &dev->subdevices[1];
	/* digital input subdevice */
	/* digital input subdevice */