From: Jongpil Jung Date: Sat, 22 Jan 2022 21:34:44 +0000 (-0800) Subject: iio: sx9360: fix iio event generation X-Git-Tag: v6.1-rc5~1693^2~55^2~184 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=19d32860dc7826ef48ea3fb80d9f1b082c4a2cf8;p=platform%2Fkernel%2Flinux-starfive.git 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: 1cdb4c47f7f5 ("iio:proximity:sx9360: Add sx9360 support") Signed-off-by: Jongpil Jung Signed-off-by: Gwendal Grignou Link: https://lore.kernel.org/r/20220122213444.745152-1-gwendal@chromium.org Signed-off-by: Jonathan Cameron --- diff --git a/drivers/iio/proximity/sx9360.c b/drivers/iio/proximity/sx9360.c index 6fd6561..3ebb30c 100644 --- a/drivers/iio/proximity/sx9360.c +++ b/drivers/iio/proximity/sx9360.c @@ -775,7 +775,7 @@ static const struct sx_common_chip_info sx9360_chip_info = { .reg_reset = SX9360_REG_RESET, .mask_enable_chan = SX9360_REG_GNRL_CTRL0_PHEN_MASK, - .stat_offset = 3, + .stat_offset = 2, .num_channels = SX9360_NUM_CHANNELS, .num_default_regs = ARRAY_SIZE(sx9360_default_regs), diff --git a/drivers/iio/proximity/sx_common.c b/drivers/iio/proximity/sx_common.c index ac8fd59..a7c0731 100644 --- a/drivers/iio/proximity/sx_common.c +++ b/drivers/iio/proximity/sx_common.c @@ -87,7 +87,7 @@ static void sx_common_push_events(struct iio_dev *indio_dev) return; } - val <<= data->chip_info->stat_offset; + val >>= data->chip_info->stat_offset; /* * Only iterate over channels with changes on proximity status that have