Re: [PATCH 1/8] iio: adc: ad_sigma_delta: use 'time_left' variable with wait_for_completion_timeout()
From: Nuno Sá
Date: Mon Apr 29 2024 - 08:02:38 EST
On Mon, 2024-04-29 at 13:33 +0200, Wolfram Sang wrote:
> There is a confusing pattern in the kernel to use a variable named 'timeout'
> to
> store the result of wait_for_completion_timeout() causing patterns like:
>
> timeout = wait_for_completion_timeout(...)
> if (!timeout) return -ETIMEDOUT;
>
> with all kinds of permutations. Use 'time_left' as a variable to make the code
> self explaining.
>
> Signed-off-by: Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx>
> ---
Reviewed-by: Nuno Sa <nuno.sa@xxxxxxxxxx>
> drivers/iio/adc/ad_sigma_delta.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/adc/ad_sigma_delta.c
> b/drivers/iio/adc/ad_sigma_delta.c
> index a602429cdde4..40ba6506bfc1 100644
> --- a/drivers/iio/adc/ad_sigma_delta.c
> +++ b/drivers/iio/adc/ad_sigma_delta.c
> @@ -206,7 +206,7 @@ int ad_sd_calibrate(struct ad_sigma_delta *sigma_delta,
> unsigned int mode, unsigned int channel)
> {
> int ret;
> - unsigned long timeout;
> + unsigned long time_left;
>
> ret = ad_sigma_delta_set_channel(sigma_delta, channel);
> if (ret)
> @@ -223,8 +223,8 @@ int ad_sd_calibrate(struct ad_sigma_delta *sigma_delta,
>
> sigma_delta->irq_dis = false;
> enable_irq(sigma_delta->spi->irq);
> - timeout = wait_for_completion_timeout(&sigma_delta->completion, 2 *
> HZ);
> - if (timeout == 0) {
> + time_left = wait_for_completion_timeout(&sigma_delta->completion, 2 *
> HZ);
> + if (time_left == 0) {
> sigma_delta->irq_dis = true;
> disable_irq_nosync(sigma_delta->spi->irq);
> ret = -EIO;