alistair23-linux/drivers/staging/comedi
Ian Abbott 677a315656 staging: comedi: ni_65xx: (bug fix) confine insn_bits to one subdevice
The `insn_bits` handler `ni_65xx_dio_insn_bits()` has a `for` loop that
currently writes (optionally) and reads back up to 5 "ports" consisting
of 8 channels each.  It reads up to 32 1-bit channels but can only read
and write a whole port at once - it needs to handle up to 5 ports as the
first channel it reads might not be aligned on a port boundary.  It
breaks out of the loop early if the next port it handles is beyond the
final port on the card.  It also breaks out early on the 5th port in the
loop if the first channel was aligned.  Unfortunately, it doesn't check
that the current port it is dealing with belongs to the comedi subdevice
the `insn_bits` handler is acting on.  That's a bug.

Redo the `for` loop to terminate after the final port belonging to the
subdevice, changing the loop variable in the process to simplify things
a bit.  The `for` loop could now try and handle more than 5 ports if the
subdevice has more than 40 channels, but the test `if (bitshift >= 32)`
ensures it will break out early after 4 or 5 ports (depending on whether
the first channel is aligned on a port boundary).  (`bitshift` will be
between -7 and 7 inclusive on the first iteration, increasing by 8 for
each subsequent operation.)

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Cc: <stable@vger.kernel.org> # 3.10.y 3.11.y 3.12.y
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-10-03 14:27:32 -07:00
..
drivers staging: comedi: ni_65xx: (bug fix) confine insn_bits to one subdevice 2013-10-03 14:27:32 -07:00
kcomedilib staging: comedi: comedi_bond: handle base channel for insn_bits 2013-08-26 06:41:56 -07:00
comedi.h staging: comedi: remove FSF address from boilerplate text 2013-05-13 17:34:22 -04:00
comedi_buf.c staging: comedi: comedi_buf: needs <linux/vmalloc.h> 2013-07-24 10:01:25 -07:00
comedi_compat32.c staging: comedi: remove FSF address from boilerplate text 2013-05-13 17:34:22 -04:00
comedi_compat32.h staging: comedi: remove FSF address from boilerplate text 2013-05-13 17:34:22 -04:00
comedi_fops.c staging tree merge for 3.12-rc1 2013-09-03 11:37:57 -07:00
comedi_internal.h staging: comedi: use a mutex when accessing driver list 2013-07-23 14:22:29 -07:00
comedi_pci.c staging: comedi: remove FSF address from boilerplate text 2013-05-13 17:34:22 -04:00
comedi_pcmcia.c staging: comedi: remove FSF address from boilerplate text 2013-05-13 17:34:22 -04:00
comedi_usb.c staging: comedi: introduce comedi_to_usb_dev() 2013-05-21 10:59:10 -07:00
comedidev.h TTY/Serial driver patches for 3.12-rc1 2013-09-03 11:38:36 -07:00
comedilib.h staging: comedi: comedi_bond: handle base channel for insn_bits 2013-08-26 06:41:56 -07:00
drivers.c staging tree merge for 3.12-rc1 2013-09-03 11:37:57 -07:00
Kconfig Staging: comedi: Fix dependencies for drivers misclassified as PCI 2013-09-17 07:39:28 -07:00
Makefile
proc.c staging: comedi: use a mutex when accessing driver list 2013-07-23 14:22:29 -07:00
range.c staging: comedi: range: tidy up comedi_check_chanlist() 2013-07-25 13:20:17 -07:00
TODO MAINTAINERS: Update the list of maintainers for staging/comedi driver. 2013-07-24 09:51:18 -07:00