]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
iio: adc: ad7768-1: Fix conversion result sign
authorSergiu Cuciurean <sergiu.cuciurean@analog.com>
Thu, 6 Mar 2025 21:00:29 +0000 (18:00 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 May 2025 05:44:26 +0000 (07:44 +0200)
commit9d708a3b72b0ff99ad9071514b199e0b51ae6154
treeb80ef1b8c6822d06b7c6bcb9df4d62a3609bb88c
parentfda3b0b782c84c036c87b17ff29bf8cac3691544
iio: adc: ad7768-1: Fix conversion result sign

[ Upstream commit 8236644f5ecb180e80ad92d691c22bc509b747bb ]

The ad7768-1 ADC output code is two's complement, meaning that the voltage
conversion result is a signed value.. Since the value is a 24 bit one,
stored in a 32 bit variable, the sign should be extended in order to get
the correct representation.

Also the channel description has been updated to signed representation,
to match the ADC specifications.

Fixes: a5f8c7da3dbe ("iio: adc: Add AD7768-1 ADC basic support")
Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com>
Signed-off-by: Jonathan Santos <Jonathan.Santos@analog.com>
Cc: <Stable@vger.kernel.org>
Link: https://patch.msgid.link/505994d3b71c2aa38ba714d909a68e021f12124c.1741268122.git.Jonathan.Santos@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/iio/adc/ad7768-1.c