* [PATCH 0/2] iio: simplify return statements
@ 2026-02-20 13:18 Antoniu Miclaus
2026-02-20 13:18 ` [PATCH 1/2] iio: adc: ad7266: simplify error return Antoniu Miclaus
2026-02-20 13:18 ` [PATCH 2/2] iio: addac: ad74413r: simplify timeout return Antoniu Miclaus
0 siblings, 2 replies; 6+ messages in thread
From: Antoniu Miclaus @ 2026-02-20 13:18 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, Cosmin Tanislav,
linux-iio, linux-kernel
Cc: Antoniu Miclaus
Minor cleanups across two IIO drivers to simplify return paths by
removing unnecessary intermediate variable assignments before returning
error codes.
Antoniu Miclaus (2):
iio: adc: ad7266: simplify error return
iio: addac: ad74413r: simplify timeout return
drivers/iio/adc/ad7266.c | 6 ++----
drivers/iio/addac/ad74413r.c | 6 ++----
2 files changed, 4 insertions(+), 8 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] iio: adc: ad7266: simplify error return
2026-02-20 13:18 [PATCH 0/2] iio: simplify return statements Antoniu Miclaus
@ 2026-02-20 13:18 ` Antoniu Miclaus
2026-02-20 14:09 ` Andy Shevchenko
2026-02-20 13:18 ` [PATCH 2/2] iio: addac: ad74413r: simplify timeout return Antoniu Miclaus
1 sibling, 1 reply; 6+ messages in thread
From: Antoniu Miclaus @ 2026-02-20 13:18 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, Cosmin Tanislav,
linux-iio, linux-kernel
Cc: Antoniu Miclaus
Return PTR_ERR() directly instead of assigning it to an intermediate
variable first.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
drivers/iio/adc/ad7266.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c
index 3364ac6c4631..0ef36c249ab8 100644
--- a/drivers/iio/adc/ad7266.c
+++ b/drivers/iio/adc/ad7266.c
@@ -409,10 +409,8 @@ static int ad7266_probe(struct spi_device *spi)
st->gpios[i] = devm_gpiod_get(&spi->dev,
ad7266_gpio_labels[i],
GPIOD_OUT_LOW);
- if (IS_ERR(st->gpios[i])) {
- ret = PTR_ERR(st->gpios[i]);
- return ret;
- }
+ if (IS_ERR(st->gpios[i]))
+ return PTR_ERR(st->gpios[i]);
}
}
} else {
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] iio: addac: ad74413r: simplify timeout return
2026-02-20 13:18 [PATCH 0/2] iio: simplify return statements Antoniu Miclaus
2026-02-20 13:18 ` [PATCH 1/2] iio: adc: ad7266: simplify error return Antoniu Miclaus
@ 2026-02-20 13:18 ` Antoniu Miclaus
2026-02-20 14:08 ` Andy Shevchenko
1 sibling, 1 reply; 6+ messages in thread
From: Antoniu Miclaus @ 2026-02-20 13:18 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, Cosmin Tanislav,
linux-iio, linux-kernel
Cc: Antoniu Miclaus
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] iio: addac: ad74413r: simplify timeout return
2026-02-20 13:18 ` [PATCH 2/2] iio: addac: ad74413r: simplify timeout return Antoniu Miclaus
@ 2026-02-20 14:08 ` Andy Shevchenko
0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2026-02-20 14:08 UTC (permalink / raw)
To: Antoniu Miclaus
Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, Cosmin Tanislav,
linux-iio, linux-kernel
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] iio: adc: ad7266: simplify error return
2026-02-20 13:18 ` [PATCH 1/2] iio: adc: ad7266: simplify error return Antoniu Miclaus
@ 2026-02-20 14:09 ` Andy Shevchenko
2026-02-22 16:50 ` Jonathan Cameron
0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2026-02-20 14:09 UTC (permalink / raw)
To: Antoniu Miclaus
Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Andy Shevchenko, Cosmin Tanislav,
linux-iio, linux-kernel
On Fri, Feb 20, 2026 at 03:18:46PM +0200, Antoniu Miclaus wrote:
> Return PTR_ERR() directly instead of assigning it to an intermediate
> variable first.
Definitely!
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] iio: adc: ad7266: simplify error return
2026-02-20 14:09 ` Andy Shevchenko
@ 2026-02-22 16:50 ` Jonathan Cameron
0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2026-02-22 16:50 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Antoniu Miclaus, Lars-Peter Clausen, Michael Hennerich,
David Lechner, Nuno Sá, Andy Shevchenko, Cosmin Tanislav,
linux-iio, linux-kernel
On Fri, 20 Feb 2026 16:09:08 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> On Fri, Feb 20, 2026 at 03:18:46PM +0200, Antoniu Miclaus wrote:
> > Return PTR_ERR() directly instead of assigning it to an intermediate
> > variable first.
>
> Definitely!
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Applied.
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-02-22 16:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-20 13:18 [PATCH 0/2] iio: simplify return statements Antoniu Miclaus
2026-02-20 13:18 ` [PATCH 1/2] iio: adc: ad7266: simplify error return Antoniu Miclaus
2026-02-20 14:09 ` Andy Shevchenko
2026-02-22 16:50 ` Jonathan Cameron
2026-02-20 13:18 ` [PATCH 2/2] iio: addac: ad74413r: simplify timeout return Antoniu Miclaus
2026-02-20 14:08 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox