]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
iio: adc: rockchip_saradc: use mask for write_enable bitfield
authorQuentin Schulz <quentin.schulz@theobroma-systems.com>
Fri, 23 Feb 2024 12:45:22 +0000 (13:45 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Wed, 28 Feb 2024 19:26:37 +0000 (19:26 +0000)
commit5b4e4b72034f85f7a0cdd147d3d729c5a22c8764
treea93c45a2e8603d8559ca0cbf797a1b6fdf320a47
parentb0a4546df24a4f8c59b2d05ae141bd70ceccc386
iio: adc: rockchip_saradc: use mask for write_enable bitfield

Some of the registers on the SARADCv2 have bits write protected except
if another bit is set. This is usually done by having the lowest 16 bits
store the data to write and the highest 16 bits specify which of the 16
lowest bits should have their value written to the hardware block.

The write_enable mask for the channel selection was incorrect because it
was just the value shifted by 16 bits, which means it would only ever
write bits and never clear them. So e.g. if someone starts a conversion
on channel 5, the lowest 4 bits would be 0x5, then starts a conversion
on channel 0, it would still be 5.

Instead of shifting the value by 16 as the mask, let's use the OR'ing of
the appropriate masks shifted by 16.

Note that this is not an issue currently because the only SARADCv2
currently supported has a reset defined in its Device Tree, that reset
resets the SARADC controller before starting a conversion on a channel.
However, this reset is handled as optional by the probe function and
thus proper masking should be used in the event an SARADCv2 without a
reset ever makes it upstream.

Fixes: 757953f8ec69 ("iio: adc: rockchip_saradc: Add support for RK3588")
Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Link: https://lore.kernel.org/r/20240223-saradcv2-chan-mask-v1-2-84b06a0f623a@theobroma-systems.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/rockchip_saradc.c