From 16331853b7d6a0d140fffd70e036fd44fe26b989 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Wed, 12 Aug 2009 15:56:14 +0000 Subject: [PATCH] =?utf8?q?Fix=20insn=5Fbits=20bitshift=20calculation=20for?= =?utf8?q?=20subdevice=20with=20non-zero=20base=5Fport.=20Thanks=20to=20J?= =?utf8?q?=C3=A9r=C3=B4me=20Carretero=20(cJ-comedi=20at=20zougloub=20dot?= =?utf8?q?=20eu)=20for=20spotting=20the=20bug.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- comedi/drivers/ni_65xx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/comedi/drivers/ni_65xx.c b/comedi/drivers/ni_65xx.c index 86e8b4d5..ebb45cfa 100644 --- a/comedi/drivers/ni_65xx.c +++ b/comedi/drivers/ni_65xx.c @@ -399,7 +399,7 @@ static int ni_65xx_dio_insn_bits(comedi_device * dev, comedi_subdevice * s, return -EINVAL; base_bitfield_channel = CR_CHAN(insn->chanspec); for (j = 0; j < max_ports_per_bitfield; ++j) { - const unsigned port = + unsigned port = sprivate(s)->base_port + ni_65xx_port_by_channel(base_bitfield_channel) + j; unsigned base_port_channel; @@ -407,7 +407,8 @@ static int ni_65xx_dio_insn_bits(comedi_device * dev, comedi_subdevice * s, int bitshift; if (port >= ni_65xx_total_num_ports(board(dev))) break; - base_port_channel = port * ni_65xx_channels_per_port; + base_port_channel = (port - sprivate(s)->base_port) * + ni_65xx_channels_per_port; port_mask = data[0]; port_data = data[1]; bitshift = base_port_channel - base_bitfield_channel; -- 2.26.2