summaryrefslogtreecommitdiff
path: root/drivers/staging/comedi/drivers/s526.c
diff options
context:
space:
mode:
authorH Hartley Sweeten <hartleys@visionengravers.com>2012-09-19 15:12:01 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-09-21 09:19:44 -0700
commit2a29edf69807a43ad7594554cea4def755443103 (patch)
tree173f421b443561de7d1630f33f345cd62dff618e /drivers/staging/comedi/drivers/s526.c
parent43a352760e6c1c073c12f6e21d02b789525e677e (diff)
staging: comedi: s526: cleanup s526_gpct_rinsn()
Use a local variable for the iobase of the channel being read. This makes the inw() calls a bit cleaner. Move the masking of the read data to make the value stored in the data array a bit clearer. The comedi core expects insn_read functions to return the number of insn data values read. For this function, the final value of 'i' is correct but change the return to 'insn->n' just to make it clear. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi/drivers/s526.c')
-rw-r--r--drivers/staging/comedi/drivers/s526.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/drivers/staging/comedi/drivers/s526.c b/drivers/staging/comedi/drivers/s526.c
index 574a0b2b698b..86b5c7b8030f 100644
--- a/drivers/staging/comedi/drivers/s526.c
+++ b/drivers/staging/comedi/drivers/s526.c
@@ -145,22 +145,25 @@ struct s526_private {
};
static int s526_gpct_rinsn(struct comedi_device *dev,
- struct comedi_subdevice *s, struct comedi_insn *insn,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
unsigned int *data)
{
unsigned int chan = CR_CHAN(insn->chanspec);
- unsigned short datalow;
- unsigned short datahigh;
+ unsigned long chan_iobase = dev->iobase + chan * 8;
+ unsigned int lo;
+ unsigned int hi;
int i;
- /* Read the low word first */
for (i = 0; i < insn->n; i++) {
- datalow = inw(dev->iobase + REG_C0L + chan * 8);
- datahigh = inw(dev->iobase + REG_C0H + chan * 8);
- data[i] = (int)(datahigh & 0x00FF);
- data[i] = (data[i] << 16) | (datalow & 0xFFFF);
+ /* Read the low word first */
+ lo = inw(chan_iobase + REG_C0L) & 0xffff;
+ hi = inw(chan_iobase + REG_C0H) & 0xff;
+
+ data[i] = (hi << 16) | lo;
}
- return i;
+
+ return insn->n;
}
static int s526_gpct_insn_config(struct comedi_device *dev,