]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
iio: adc: nxp-sar-adc: Fix the delay calculation in nxp_sar_adc_wait_for()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tue, 19 May 2026 21:56:06 +0000 (23:56 +0200)
committerJonathan Cameron <jic23@kernel.org>
Sat, 4 Jul 2026 23:02:10 +0000 (00:02 +0100)
commita9f41809bf1bd8e5c1bc4b6a1052adac58eb7ab6
tree86bae09ef8188cf9d5128fa66fa2b5a3a47781c2
parenta00ffd15674bfaf8b906503c1600e3d8709af56c
iio: adc: nxp-sar-adc: Fix the delay calculation in nxp_sar_adc_wait_for()

The original code was using ndelay() twice. In one case the delay
is calculated as 1/3 of ADC clock and in the other as 80 ADC clocks.
But according to the comments in all cases it should be a multiplier
of the ADC clock, and not a fraction of it. Inadvertently
nxp_sar_adc_wait_for() takes the wrong case and spread it over
the code make it wrong in all places. Fix this by modifying a helper
to correctly use the multiplier.

Fixes: 7e5c0f97c66a ("iio: adc: nxp-sar-adc: Avoid division by zero")
Fixes: 4434072a893e ("iio: adc: Add the NXP SAR ADC support for the s32g2/3 platforms")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260416090122.758990-1-andriy.shevchenko%40linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Stepan Ionichev <sozdayvek@gmail.com>
Acked-by: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/adc/nxp-sar-adc.c