Introduce a helper function to get a two's complement sample from the FIFO and munge it to the offset binary format that comedi uses. Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx> Cc: Ian Abbott <abbotti@xxxxxxxxx> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/staging/comedi/drivers/quatech_daqp_cs.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c index d2e9049..23c79e3 100644 --- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c +++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c @@ -169,6 +169,20 @@ static int daqp_ai_cancel(struct comedi_device *dev, return 0; } +unsigned int daqp_ai_get_sample(struct comedi_device *dev, + struct comedi_subdevice *s) +{ + unsigned int val; + + /* + * Get a two's complement sample from the FIFO and + * return the munged offset binary value. + */ + val = inb(dev->iobase + DAQP_FIFO); + val |= inb(dev->iobase + DAQP_FIFO) << 8; + return comedi_offset_munge(s, val); +} + static irqreturn_t daqp_interrupt(int irq, void *dev_id) { struct comedi_device *dev = dev_id; @@ -190,10 +204,7 @@ static irqreturn_t daqp_interrupt(int irq, void *dev_id) break; } - data = inb(dev->iobase + DAQP_FIFO); - data |= inb(dev->iobase + DAQP_FIFO) << 8; - data ^= 0x8000; - + data = daqp_ai_get_sample(dev, s); comedi_buf_write_samples(s, &data, 1); if (cmd->stop_src == TRIG_COUNT && @@ -309,9 +320,7 @@ static int daqp_ai_insn_read(struct comedi_device *dev, /* clear the status event flags */ inb(dev->iobase + DAQP_STATUS); - data[i] = inb(dev->iobase + DAQP_FIFO); - data[i] |= inb(dev->iobase + DAQP_FIFO) << 8; - data[i] ^= 0x8000; + data[i] = daqp_ai_get_sample(dev, s); } /* stop any conversions and clear the status event flags */ -- 2.5.1 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel