OSDN Git Service

staging: iio: adt7316: fix the dac write calculation
authorJeremy Fertic <jeremyfertic@gmail.com>
Sun, 23 Dec 2018 04:57:43 +0000 (21:57 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 May 2019 05:19:11 +0000 (07:19 +0200)
commit17b600cce96c3a181054b4fa1ff88ea71f97fb66
tree4fc325570d39b03bbe8a813cb97b6efc978dfff9
parent8c5a4013e6cff5eeeb249c023db83ad4a086c0e1
staging: iio: adt7316: fix the dac write calculation

commit 78accaea117c1ae878774974fab91ac4a0b0e2b0 upstream.

The lsb calculation is not masking the correct bits from the user input.
Subtract 1 from (1 << offset) to correctly set up the mask to be applied
to user input.

The lsb register stores its value starting at the bit 7 position.
adt7316_store_DAC() currently assumes the value is at the other end of the
register. Shift the lsb value before storing it in a new variable lsb_reg,
and write this variable to the lsb register.

Fixes: 35f6b6b86ede ("staging: iio: new ADT7316/7/8 and ADT7516/7/9 driver")
Signed-off-by: Jeremy Fertic <jeremyfertic@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/iio/addac/adt7316.c