diff options
author | Stephen Boyd <swboyd@chromium.org> | 2022-03-25 01:29:28 +0300 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2022-04-04 11:19:02 +0300 |
commit | 108e4d4de2b58011eafd14581b6ea7469f1fc467 (patch) | |
tree | 0aa0517222045c96eab7ac56b80ec44281b8679a /drivers/iio/magnetometer | |
parent | 74a53a959028e5f28e3c0e9445a876e5c8da147c (diff) | |
download | linux-108e4d4de2b58011eafd14581b6ea7469f1fc467.tar.xz |
iio:proximity:sx9324: Fix hardware gain read/write
There are four possible gain values according to 'sx9324_gain_vals[]':
1, 2, 4, and 8
The values are off by one when writing and reading the register. The
bits should be set according to this equation:
ilog2(<gain>) + 1
so that a gain of 8 is 0x4 in the register field and a gain of 4 is 0x3
in the register field, etc. Note that a gain of 0 is reserved per the
datasheet. The default gain (SX9324_REG_PROX_CTRL0_GAIN_1) is also
wrong. It should be 0x1 << 3, i.e. 0x8, not 0x80 which is setting the
reserved bit 7.
Fix this all up to properly handle the hardware gain and return errors
for invalid settings.
Fixes: 4c18a890dff8 ("iio:proximity:sx9324: Add SX9324 support")
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Link: https://lore.kernel.org/r/20220324222928.874522-1-swboyd@chromium.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/magnetometer')
0 files changed, 0 insertions, 0 deletions