mirror of
https://github.com/FEX-Emu/linux.git
synced 2025-01-01 14:52:32 +00:00
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>
This commit is contained in:
parent
43a352760e
commit
2a29edf698
@ -145,22 +145,25 @@ struct s526_private {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int s526_gpct_rinsn(struct comedi_device *dev,
|
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 *data)
|
||||||
{
|
{
|
||||||
unsigned int chan = CR_CHAN(insn->chanspec);
|
unsigned int chan = CR_CHAN(insn->chanspec);
|
||||||
unsigned short datalow;
|
unsigned long chan_iobase = dev->iobase + chan * 8;
|
||||||
unsigned short datahigh;
|
unsigned int lo;
|
||||||
|
unsigned int hi;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Read the low word first */
|
|
||||||
for (i = 0; i < insn->n; i++) {
|
for (i = 0; i < insn->n; i++) {
|
||||||
datalow = inw(dev->iobase + REG_C0L + chan * 8);
|
/* Read the low word first */
|
||||||
datahigh = inw(dev->iobase + REG_C0H + chan * 8);
|
lo = inw(chan_iobase + REG_C0L) & 0xffff;
|
||||||
data[i] = (int)(datahigh & 0x00FF);
|
hi = inw(chan_iobase + REG_C0H) & 0xff;
|
||||||
data[i] = (data[i] << 16) | (datalow & 0xFFFF);
|
|
||||||
|
data[i] = (hi << 16) | lo;
|
||||||
}
|
}
|
||||||
return i;
|
|
||||||
|
return insn->n;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int s526_gpct_insn_config(struct comedi_device *dev,
|
static int s526_gpct_insn_config(struct comedi_device *dev,
|
||||||
|
Loading…
Reference in New Issue
Block a user