Commit 19d32860 authored by Jongpil Jung's avatar Jongpil Jung Committed by Jonathan Cameron

iio: sx9360: fix iio event generation

To convert SX9360 status register ["REG_STAT"], into a channel
index, we need to right shift by |stat_offset|, not left shift.
Also the PROXSTAT bit (3) is for channel 1 (PHM, Phase Measured), not (PHR,
Phase Reference, channel 0), so the offset is 2 instead of 3.

Fixes: 1cdb4c47 ("iio:proximity:sx9360: Add sx9360 support")
Signed-off-by: default avatarJongpil Jung <jongpil19.jung@samsung.com>
Signed-off-by: default avatarGwendal Grignou <gwendal@chromium.org>
Link: https://lore.kernel.org/r/20220122213444.745152-1-gwendal@chromium.orgSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent a5e9b2dd
...@@ -775,7 +775,7 @@ static const struct sx_common_chip_info sx9360_chip_info = { ...@@ -775,7 +775,7 @@ static const struct sx_common_chip_info sx9360_chip_info = {
.reg_reset = SX9360_REG_RESET, .reg_reset = SX9360_REG_RESET,
.mask_enable_chan = SX9360_REG_GNRL_CTRL0_PHEN_MASK, .mask_enable_chan = SX9360_REG_GNRL_CTRL0_PHEN_MASK,
.stat_offset = 3, .stat_offset = 2,
.num_channels = SX9360_NUM_CHANNELS, .num_channels = SX9360_NUM_CHANNELS,
.num_default_regs = ARRAY_SIZE(sx9360_default_regs), .num_default_regs = ARRAY_SIZE(sx9360_default_regs),
......
...@@ -87,7 +87,7 @@ static void sx_common_push_events(struct iio_dev *indio_dev) ...@@ -87,7 +87,7 @@ static void sx_common_push_events(struct iio_dev *indio_dev)
return; return;
} }
val <<= data->chip_info->stat_offset; val >>= data->chip_info->stat_offset;
/* /*
* Only iterate over channels with changes on proximity status that have * Only iterate over channels with changes on proximity status that have
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment