]> git.baikalelectronics.ru Git - kernel.git/commit
staging: comedi: s626: fix value written by s626_set_dac()
authorIan Abbott <abbotti@mev.co.uk>
Wed, 6 Nov 2013 20:45:59 +0000 (20:45 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 25 Nov 2013 17:09:07 +0000 (09:09 -0800)
commit346ed9f17f7684e0aad6ccef7a075bf6caa3bbb0
treeb4551fd38994831f3a73db2fd5eb48908ea2e8ce
parentce952cf944a82457cc42daccb75bcc81aeca6dde
staging: comedi: s626: fix value written by s626_set_dac()

I broke `s626_set_dac()` by changing the type of the `dacdata` parameter
from `short` to `unsigned short`.  It's actually designed to take a
signed value in the range -0x1fff to +0x2000 although values above
0x1fff get clamped to 0x1fff.  (We could change the `maxdata` value to
0x1ffe to avoid the clamping, but `maxdata` values are usually a power
of 2 minus 1.)  The bug results in all negative values passed to the
function being changed to +0x1fff by the clamp.  Change the parameter
type to `int16_t` to fix the problem.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/s626.c