iio: adc: imx93: fix a signedness bug in imx93_adc_read_raw()
authorDan Carpenter <error27@gmail.com>
Tue, 14 Feb 2023 15:47:30 +0000 (18:47 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 13 May 2023 16:54:56 +0000 (17:54 +0100)
commit20f291b88ecf23f674ee2ed980a4d93b7f16a06f
treeb37b812331b0a5dbf823776bfe123141960fc734
parentac9a78681b921877518763ba0e89202254349d1b
iio: adc: imx93: fix a signedness bug in imx93_adc_read_raw()

The problem is these lines:

ret = vref_uv = regulator_get_voltage(adc->vref);
if (ret < 0)

The "ret" variable is type long and "vref_uv" is u32 so that means
the condition can never be true on a 64bit system.  A negative error
code from regulator_get_voltage() would be cast to a high positive
u32 value and then remain a high positive value when cast to a long.

The "ret" variable only ever stores ints so it should be declared as
an int.  We can delete the "vref_uv" variable and use "ret" directly.

Fixes: 7d02296ac8b8 ("iio: adc: add imx93 adc support")
Signed-off-by: Dan Carpenter <error27@gmail.com>
Reviewed-by: Haibo Chen <haibo.chen@nxp.com>
Link: https://lore.kernel.org/r/Y+utEvjfjQRQo2QB@kili
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/imx93_adc.c