Staging: comedi: ni_65xx.c: fix insn_bits shift calculation.

Fix insn_bits bitshift calculation for subdevice with non-zero
base_port.

Thanks to cJ-comedi at zougloub dot eu for spotting the bug.

Signed-off-by: Frank Mori Hess <fmhess@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Ian Abbott 2009-09-21 16:01:56 -04:00 committed by Greg Kroah-Hartman
parent 5044a2c0e0
commit 2b49d7c40e

View File

@ -418,15 +418,15 @@ static int ni_65xx_dio_insn_bits(struct comedi_device *dev,
return -EINVAL; return -EINVAL;
base_bitfield_channel = CR_CHAN(insn->chanspec); base_bitfield_channel = CR_CHAN(insn->chanspec);
for (j = 0; j < max_ports_per_bitfield; ++j) { for (j = 0; j < max_ports_per_bitfield; ++j) {
const unsigned port_offset = ni_65xx_port_by_channel(base_bitfield_channel) + j;
const unsigned port = const unsigned port =
sprivate(s)->base_port + sprivate(s)->base_port + port_offset;
ni_65xx_port_by_channel(base_bitfield_channel) + j;
unsigned base_port_channel; unsigned base_port_channel;
unsigned port_mask, port_data, port_read_bits; unsigned port_mask, port_data, port_read_bits;
int bitshift; int bitshift;
if (port >= ni_65xx_total_num_ports(board(dev))) if (port >= ni_65xx_total_num_ports(board(dev)))
break; break;
base_port_channel = port * ni_65xx_channels_per_port; base_port_channel = port_offset * ni_65xx_channels_per_port;
port_mask = data[0]; port_mask = data[0];
port_data = data[1]; port_data = data[1];
bitshift = base_port_channel - base_bitfield_channel; bitshift = base_port_channel - base_bitfield_channel;