public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] iio: remove redundant else after return
@ 2026-02-20 13:33 Antoniu Miclaus
  2026-02-20 13:33 ` [PATCH 1/5] iio: adc: ad7298: " Antoniu Miclaus
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Antoniu Miclaus @ 2026-02-20 13:33 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, Antoniu Miclaus,
	linux-iio, linux-kernel

Remove redundant else branches after return statements across several
IIO drivers (ad7298, ad7606, ad5592r, ad5758, admv8818) to simplify
control flow.

Antoniu Miclaus (5):
  iio: adc: ad7298: remove redundant else after return
  iio: adc: ad7606: remove redundant else after return
  iio: dac: ad5592r-base: remove redundant else after return
  iio: dac: ad5758: remove redundant else after return
  iio: filter: admv8818: remove redundant else after return

 drivers/iio/adc/ad7298.c       | 4 ++--
 drivers/iio/adc/ad7606.c       | 4 ++--
 drivers/iio/dac/ad5592r-base.c | 4 ++--
 drivers/iio/dac/ad5758.c       | 6 +++---
 drivers/iio/filter/admv8818.c  | 4 ++--
 5 files changed, 11 insertions(+), 11 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/5] iio: adc: ad7298: remove redundant else after return
  2026-02-20 13:33 [PATCH 0/5] iio: remove redundant else after return Antoniu Miclaus
@ 2026-02-20 13:33 ` Antoniu Miclaus
  2026-02-20 13:33 ` [PATCH 2/5] iio: adc: ad7606: " Antoniu Miclaus
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Antoniu Miclaus @ 2026-02-20 13:33 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, Antoniu Miclaus,
	linux-iio, linux-kernel

The else returning the internal reference voltage in
ad7298_get_ref_voltage() is unnecessary since the if block for the
external regulator already returns.

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

diff --git a/drivers/iio/adc/ad7298.c b/drivers/iio/adc/ad7298.c
index 7c0538ea15c8..e775d84da333 100644
--- a/drivers/iio/adc/ad7298.c
+++ b/drivers/iio/adc/ad7298.c
@@ -216,9 +216,9 @@ static int ad7298_get_ref_voltage(struct ad7298_state *st)
 			return vref;
 
 		return vref / 1000;
-	} else {
-		return AD7298_INTREF_mV;
 	}
+
+	return AD7298_INTREF_mV;
 }
 
 static int ad7298_read_raw(struct iio_dev *indio_dev,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/5] iio: adc: ad7606: remove redundant else after return
  2026-02-20 13:33 [PATCH 0/5] iio: remove redundant else after return Antoniu Miclaus
  2026-02-20 13:33 ` [PATCH 1/5] iio: adc: ad7298: " Antoniu Miclaus
@ 2026-02-20 13:33 ` Antoniu Miclaus
  2026-02-20 13:33 ` [PATCH 3/5] iio: dac: ad5592r-base: " Antoniu Miclaus
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Antoniu Miclaus @ 2026-02-20 13:33 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, Antoniu Miclaus,
	linux-iio, linux-kernel

The else performing the register write in ad7606_reg_access() is
unnecessary since the if block for the register read already returns.

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

diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
index d9271894f091..8ef3f7b8a6a4 100644
--- a/drivers/iio/adc/ad7606.c
+++ b/drivers/iio/adc/ad7606.c
@@ -540,9 +540,9 @@ static int ad7606_reg_access(struct iio_dev *indio_dev,
 			return ret;
 		*readval = ret;
 		return 0;
-	} else {
-		return st->bops->reg_write(st, reg, writeval);
 	}
+
+	return st->bops->reg_write(st, reg, writeval);
 }
 
 static int ad7606_pwm_set_high(struct ad7606_state *st)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/5] iio: dac: ad5592r-base: remove redundant else after return
  2026-02-20 13:33 [PATCH 0/5] iio: remove redundant else after return Antoniu Miclaus
  2026-02-20 13:33 ` [PATCH 1/5] iio: adc: ad7298: " Antoniu Miclaus
  2026-02-20 13:33 ` [PATCH 2/5] iio: adc: ad7606: " Antoniu Miclaus
@ 2026-02-20 13:33 ` Antoniu Miclaus
  2026-02-20 13:33 ` [PATCH 4/5] iio: dac: ad5758: " Antoniu Miclaus
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Antoniu Miclaus @ 2026-02-20 13:33 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, Antoniu Miclaus,
	linux-iio, linux-kernel

The else returning the internal 2500mV fallback in ad5592r_get_vref()
is unnecessary since the if block for the external regulator already
returns.

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

diff --git a/drivers/iio/dac/ad5592r-base.c b/drivers/iio/dac/ad5592r-base.c
index 4720733d66b2..a8c10ca238d0 100644
--- a/drivers/iio/dac/ad5592r-base.c
+++ b/drivers/iio/dac/ad5592r-base.c
@@ -179,9 +179,9 @@ static int ad5592r_get_vref(struct ad5592r_state *st)
 			return ret;
 
 		return ret / 1000;
-	} else {
-		return 2500;
 	}
+
+	return 2500;
 }
 
 static int ad5592r_set_channel_modes(struct ad5592r_state *st)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/5] iio: dac: ad5758: remove redundant else after return
  2026-02-20 13:33 [PATCH 0/5] iio: remove redundant else after return Antoniu Miclaus
                   ` (2 preceding siblings ...)
  2026-02-20 13:33 ` [PATCH 3/5] iio: dac: ad5592r-base: " Antoniu Miclaus
@ 2026-02-20 13:33 ` Antoniu Miclaus
  2026-02-20 13:33 ` [PATCH 5/5] iio: filter: admv8818: " Antoniu Miclaus
  2026-02-20 14:13 ` [PATCH 0/5] iio: " Andy Shevchenko
  5 siblings, 0 replies; 10+ messages in thread
From: Antoniu Miclaus @ 2026-02-20 13:33 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, Antoniu Miclaus,
	linux-iio, linux-kernel

The else falling back to software reset in ad5758_reset() is
unnecessary since the if block for the GPIO hardware reset already
returns.

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

diff --git a/drivers/iio/dac/ad5758.c b/drivers/iio/dac/ad5758.c
index 4ed4fda76ea9..c4424a80a35a 100644
--- a/drivers/iio/dac/ad5758.c
+++ b/drivers/iio/dac/ad5758.c
@@ -483,10 +483,10 @@ static int ad5758_reset(struct ad5758_state *st)
 		usleep_range(100, 1000);
 
 		return 0;
-	} else {
-		/* Perform a software reset */
-		return ad5758_soft_reset(st);
 	}
+
+	/* Perform a software reset */
+	return ad5758_soft_reset(st);
 }
 
 static int ad5758_reg_access(struct iio_dev *indio_dev,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/5] iio: filter: admv8818: remove redundant else after return
  2026-02-20 13:33 [PATCH 0/5] iio: remove redundant else after return Antoniu Miclaus
                   ` (3 preceding siblings ...)
  2026-02-20 13:33 ` [PATCH 4/5] iio: dac: ad5758: " Antoniu Miclaus
@ 2026-02-20 13:33 ` Antoniu Miclaus
  2026-02-20 14:14   ` Andy Shevchenko
  2026-02-20 14:13 ` [PATCH 0/5] iio: " Andy Shevchenko
  5 siblings, 1 reply; 10+ messages in thread
From: Antoniu Miclaus @ 2026-02-20 13:33 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, Antoniu Miclaus,
	linux-iio, linux-kernel

The else in admv8818_init() is unnecessary since the if block already
returns after calling admv8818_rfin_band_select() when clkin is present.

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

diff --git a/drivers/iio/filter/admv8818.c b/drivers/iio/filter/admv8818.c
index 19f823446cda..e494fd33911b 100644
--- a/drivers/iio/filter/admv8818.c
+++ b/drivers/iio/filter/admv8818.c
@@ -695,8 +695,8 @@ static int admv8818_init(struct admv8818_state *st)
 
 	if (st->clkin)
 		return admv8818_rfin_band_select(st);
-	else
-		return 0;
+
+	return 0;
 }
 
 static int admv8818_clk_setup(struct admv8818_state *st)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/5] iio: remove redundant else after return
  2026-02-20 13:33 [PATCH 0/5] iio: remove redundant else after return Antoniu Miclaus
                   ` (4 preceding siblings ...)
  2026-02-20 13:33 ` [PATCH 5/5] iio: filter: admv8818: " Antoniu Miclaus
@ 2026-02-20 14:13 ` Andy Shevchenko
  2026-02-20 14:16   ` Andy Shevchenko
  2026-02-22 16:43   ` Jonathan Cameron
  5 siblings, 2 replies; 10+ messages in thread
From: Andy Shevchenko @ 2026-02-20 14:13 UTC (permalink / raw)
  To: Antoniu Miclaus
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, linux-iio,
	linux-kernel

On Fri, Feb 20, 2026 at 03:33:29PM +0200, Antoniu Miclaus wrote:
> Remove redundant else branches after return statements across several
> IIO drivers (ad7298, ad7606, ad5592r, ad5758, admv8818) to simplify
> control flow.

While technically you are correct, the only patch 5 makes sense to me.
The rest might be better with 'else' be present. It depends on the logic
between the lines, if they are of the same semantics and it's not about
returning error code vs. 0 (success), it may be better to read them
if they are started on the same column.

TL;DR: I am not going to NAK, but patches 1-4 is an unneeded churn to me.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 5/5] iio: filter: admv8818: remove redundant else after return
  2026-02-20 13:33 ` [PATCH 5/5] iio: filter: admv8818: " Antoniu Miclaus
@ 2026-02-20 14:14   ` Andy Shevchenko
  0 siblings, 0 replies; 10+ messages in thread
From: Andy Shevchenko @ 2026-02-20 14:14 UTC (permalink / raw)
  To: Antoniu Miclaus
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, linux-iio,
	linux-kernel

On Fri, Feb 20, 2026 at 03:33:34PM +0200, Antoniu Miclaus wrote:
> The else in admv8818_init() is unnecessary since the if block already
> returns after calling admv8818_rfin_band_select() when clkin is present.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/5] iio: remove redundant else after return
  2026-02-20 14:13 ` [PATCH 0/5] iio: " Andy Shevchenko
@ 2026-02-20 14:16   ` Andy Shevchenko
  2026-02-22 16:43   ` Jonathan Cameron
  1 sibling, 0 replies; 10+ messages in thread
From: Andy Shevchenko @ 2026-02-20 14:16 UTC (permalink / raw)
  To: Antoniu Miclaus
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, linux-iio,
	linux-kernel

On Fri, Feb 20, 2026 at 04:13:35PM +0200, Andy Shevchenko wrote:
> On Fri, Feb 20, 2026 at 03:33:29PM +0200, Antoniu Miclaus wrote:
> > Remove redundant else branches after return statements across several
> > IIO drivers (ad7298, ad7606, ad5592r, ad5758, admv8818) to simplify
> > control flow.
> 
> While technically you are correct, the only patch 5 makes sense to me.
> The rest might be better with 'else' be present. It depends on the logic
> between the lines, if they are of the same semantics and it's not about
> returning error code vs. 0 (success), it may be better to read them
> if they are started on the same column.
> 
> TL;DR: I am not going to NAK, but patches 1-4 is an unneeded churn to me.

For the record you may look at my patches in the Git history on the same
matter, they do not kill all 'else':s in such cases.

git log --no-merges -p --author="Andy Shevchenko" --grep "redundant 'else'"

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/5] iio: remove redundant else after return
  2026-02-20 14:13 ` [PATCH 0/5] iio: " Andy Shevchenko
  2026-02-20 14:16   ` Andy Shevchenko
@ 2026-02-22 16:43   ` Jonathan Cameron
  1 sibling, 0 replies; 10+ messages in thread
From: Jonathan Cameron @ 2026-02-22 16:43 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Antoniu Miclaus, Lars-Peter Clausen, Michael Hennerich,
	David Lechner, Nuno Sá, Andy Shevchenko, linux-iio,
	linux-kernel

On Fri, 20 Feb 2026 16:13:30 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Fri, Feb 20, 2026 at 03:33:29PM +0200, Antoniu Miclaus wrote:
> > Remove redundant else branches after return statements across several
> > IIO drivers (ad7298, ad7606, ad5592r, ad5758, admv8818) to simplify
> > control flow.  
> 
> While technically you are correct, the only patch 5 makes sense to me.
> The rest might be better with 'else' be present. It depends on the logic
> between the lines, if they are of the same semantics and it's not about
> returning error code vs. 0 (success), it may be better to read them
> if they are started on the same column.

I agree.  When it's a choice between two 'good' paths and the author
felt if / else made that choice aspect clear than I've always taken the
view that that is reasonable.

So I've picked up patch 5 but not the others.  5 was a little stronger as
it's if (A) do something else do nothing.

> 
> TL;DR: I am not going to NAK, but patches 1-4 is an unneeded churn to me.
> 


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-02-22 16:44 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-20 13:33 [PATCH 0/5] iio: remove redundant else after return Antoniu Miclaus
2026-02-20 13:33 ` [PATCH 1/5] iio: adc: ad7298: " Antoniu Miclaus
2026-02-20 13:33 ` [PATCH 2/5] iio: adc: ad7606: " Antoniu Miclaus
2026-02-20 13:33 ` [PATCH 3/5] iio: dac: ad5592r-base: " Antoniu Miclaus
2026-02-20 13:33 ` [PATCH 4/5] iio: dac: ad5758: " Antoniu Miclaus
2026-02-20 13:33 ` [PATCH 5/5] iio: filter: admv8818: " Antoniu Miclaus
2026-02-20 14:14   ` Andy Shevchenko
2026-02-20 14:13 ` [PATCH 0/5] iio: " Andy Shevchenko
2026-02-20 14:16   ` Andy Shevchenko
2026-02-22 16:43   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox