[PATCH 2/2] iio: addac: ad74413r: simplify timeout return

Antoniu Miclaus posted 2 patches 1 month, 1 week ago
[PATCH 2/2] iio: addac: ad74413r: simplify timeout return
Posted by Antoniu Miclaus 1 month, 1 week ago
Return -ETIMEDOUT directly instead of assigning it to an intermediate
variable first.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
 drivers/iio/addac/ad74413r.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/addac/ad74413r.c b/drivers/iio/addac/ad74413r.c
index a20b4d48c5f7..b1cf8a011277 100644
--- a/drivers/iio/addac/ad74413r.c
+++ b/drivers/iio/addac/ad74413r.c
@@ -841,10 +841,8 @@ static int _ad74413r_get_single_adc_result(struct ad74413r_state *st,
 
 	ret = wait_for_completion_timeout(&st->adc_data_completion,
 					  msecs_to_jiffies(1000));
-	if (!ret) {
-		ret = -ETIMEDOUT;
-		return ret;
-	}
+	if (!ret)
+		return -ETIMEDOUT;
 
 	ret = regmap_read(st->regmap, AD74413R_REG_ADC_RESULT_X(channel),
 			  &uval);
-- 
2.43.0
Re: [PATCH 2/2] iio: addac: ad74413r: simplify timeout return
Posted by Andy Shevchenko 1 month, 1 week ago
On Fri, Feb 20, 2026 at 03:18:47PM +0200, Antoniu Miclaus wrote:
> Return -ETIMEDOUT directly instead of assigning it to an intermediate
> variable first.

...

>  	ret = wait_for_completion_timeout(&st->adc_data_completion,
>  					  msecs_to_jiffies(1000));
> -	if (!ret) {
> -		ret = -ETIMEDOUT;
> -		return ret;
> -	}
> +	if (!ret)
> +		return -ETIMEDOUT;

I would prefer to have just

	if (!wait_for_completion_timeout(&st->adc_data_completion,
					 msecs_to_jiffies(1000)))
		return -ETIMEDOUT;

Using ret in a different semantics might lead to subtle issues in case some
code sneaks in and out of a sudden will recognize positive value as something
else.

-- 
With Best Regards,
Andy Shevchenko