From d808d4eb90ab9fa54a23c069bbcbaf7289bdb710 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Mon, 21 Sep 2009 16:05:01 -0400 Subject: Staging: comedi: ni_65xx.c: fix output inversion problem. From: Ian Abbott When reading DO subdevice with inverted outputs invert the values read back from the ports to match the inversion of values written. Signed-off-by: Frank Mori Hess Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_65xx.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/staging/comedi/drivers/ni_65xx.c +++ b/drivers/staging/comedi/drivers/ni_65xx.c @@ -457,6 +457,12 @@ static int ni_65xx_dio_insn_bits(struct port_read_bits = readb(private(dev)->mite->daq_io_addr + Port_Data(port)); /* printk("read 0x%x from port %i\n", port_read_bits, port); */ + if (s->type == COMEDI_SUBD_DO && board(dev)->invert_outputs) { + /* Outputs inverted, so invert value read back from + * DO subdevice. (Does not apply to boards with DIO + * subdevice.) */ + port_read_bits ^= 0xFF; + } if (bitshift > 0) { port_read_bits <<= bitshift; } else {