The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] iio: adc: ad7779: Initialize completion before requesting IRQ
@ 2026-06-27 11:22 Moksh Panicker
  2026-06-27 17:26 ` Joshua Crofts
  0 siblings, 1 reply; 7+ messages in thread
From: Moksh Panicker @ 2026-06-27 11:22 UTC (permalink / raw)
  To: jic23
  Cc: nuno.sa, Michael.Hennerich, dlechner, linux-iio, linux-kernel,
	stable, skhan, Moksh Panicker

init_completion() is called after devm_request_irq() in
ad7779_setup_trigger(). If the IRQ fires before init_completion()
runs, the completion is in an undefined state.

Move init_completion() before devm_request_irq() to ensure the
completion is ready before the IRQ handler can signal it.

Fixes: c9a3f8c7bfcb ("drivers: iio: adc: add support for ad777x family")
Cc: stable@vger.kernel.org
Signed-off-by: Moksh Panicker <mokshpanicker.7@gmail.com>
---
 drivers/iio/adc/ad7779.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/adc/ad7779.c b/drivers/iio/adc/ad7779.c
index 695cc79e78da..db8f5f4c6d6a 100644
--- a/drivers/iio/adc/ad7779.c
+++ b/drivers/iio/adc/ad7779.c
@@ -838,6 +838,8 @@ static int ad7779_setup_without_backend(struct ad7779_state *st, struct iio_dev
 	st->trig->ops = &ad7779_trigger_ops;
 
 	iio_trigger_set_drvdata(st->trig, st);
+	init_completion(&st->completion);
+
 
 	ret = devm_request_irq(dev, st->spi->irq, iio_trigger_generic_data_rdy_poll,
 			       IRQF_NO_THREAD | IRQF_NO_AUTOEN, indio_dev->name,
@@ -852,8 +854,6 @@ static int ad7779_setup_without_backend(struct ad7779_state *st, struct iio_dev
 
 	indio_dev->trig = iio_trigger_get(st->trig);
 
-	init_completion(&st->completion);
-
 	ret = devm_iio_triggered_buffer_setup(dev, indio_dev,
 					      &iio_pollfunc_store_time,
 					      &ad7779_trigger_handler,
-- 
2.34.1


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

* Re: [PATCH] iio: adc: ad7779: Initialize completion before requesting IRQ
  2026-06-27 11:22 [PATCH] iio: adc: ad7779: Initialize completion before requesting IRQ Moksh Panicker
@ 2026-06-27 17:26 ` Joshua Crofts
  2026-06-28  7:14   ` [PATCH 1/2] iio: adc: ad7779: Remove unused completion field Moksh Panicker
  0 siblings, 1 reply; 7+ messages in thread
From: Joshua Crofts @ 2026-06-27 17:26 UTC (permalink / raw)
  To: Moksh Panicker
  Cc: jic23, nuno.sa, Michael.Hennerich, dlechner, linux-iio,
	linux-kernel, stable, skhan

On Sat, 27 Jun 2026 11:22:05 +0000
Moksh Panicker <mokshpanicker.7@gmail.com> wrote:

> init_completion() is called after devm_request_irq() in
> ad7779_setup_trigger(). If the IRQ fires before init_completion()
> runs, the completion is in an undefined state.

This is probably impossible, as devm_request_irq() is called with
IRQF_NO_AUTOEN as a parameter, therefore IRQs are enabled manually
in the code.

> Move init_completion() before devm_request_irq() to ensure the
> completion is ready before the IRQ handler can signal it.
> 
> Fixes: c9a3f8c7bfcb ("drivers: iio: adc: add support for ad777x family")
> Cc: stable@vger.kernel.org
> Signed-off-by: Moksh Panicker <mokshpanicker.7@gmail.com>
> ---
>  drivers/iio/adc/ad7779.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7779.c b/drivers/iio/adc/ad7779.c
> index 695cc79e78da..db8f5f4c6d6a 100644
> --- a/drivers/iio/adc/ad7779.c
> +++ b/drivers/iio/adc/ad7779.c
> @@ -838,6 +838,8 @@ static int ad7779_setup_without_backend(struct ad7779_state *st, struct iio_dev
>  	st->trig->ops = &ad7779_trigger_ops;
>  
>  	iio_trigger_set_drvdata(st->trig, st);
> +	init_completion(&st->completion);

Is there really any point in having this when st->completion isn't
used anywhere in the driver? I'd rather be for removing this function
call and the struct completion from struct ad7779_state.

> +
>  
>  	ret = devm_request_irq(dev, st->spi->irq, iio_trigger_generic_data_rdy_poll,
>  			       IRQF_NO_THREAD | IRQF_NO_AUTOEN, indio_dev->name,

Unrelated, however the dev_err_probe() call below this is unnecessary,
as devm_request_irq already returns a dev_err_probe on failure. Consider
sending a patch for this as well.

-- 
Kind regards

CJD

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

* [PATCH 1/2] iio: adc: ad7779: Remove unused completion field
  2026-06-27 17:26 ` Joshua Crofts
@ 2026-06-28  7:14   ` Moksh Panicker
  2026-06-28  7:14     ` [PATCH 2/2] iio: adc: ad7779: Remove redundant dev_err_probe() after devm_request_irq() Moksh Panicker
  2026-06-28 11:41     ` [PATCH 1/2] iio: adc: ad7779: Remove unused completion field Joshua Crofts
  0 siblings, 2 replies; 7+ messages in thread
From: Moksh Panicker @ 2026-06-28  7:14 UTC (permalink / raw)
  To: jic23
  Cc: nuno.sa, Michael.Hennerich, dlechner, joshua.crofts1, linux-iio,
	linux-kernel, skhan, Moksh Panicker

struct ad7779_state contains a completion field that is initialized
in ad7779_setup_without_backend() but never waited on or signaled
anywhere in the driver. Remove the dead code.

Suggested-by: Joshua Crofts <joshua.crofts1@gmail.com>
Signed-off-by: Moksh Panicker <mokshpanicker.7@gmail.com>
---
 drivers/iio/adc/ad7779.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/iio/adc/ad7779.c b/drivers/iio/adc/ad7779.c
index 695cc79e78da..c1a99b4c1256 100644
--- a/drivers/iio/adc/ad7779.c
+++ b/drivers/iio/adc/ad7779.c
@@ -143,7 +143,6 @@ struct ad7779_state {
 	const struct ad7779_chip_info *chip_info;
 	struct clk *mclk;
 	struct iio_trigger *trig;
-	struct completion completion;
 	unsigned int sampling_freq;
 	enum ad7779_filter filter_enabled;
 	struct iio_backend *back;
@@ -852,7 +851,6 @@ static int ad7779_setup_without_backend(struct ad7779_state *st, struct iio_dev
 
 	indio_dev->trig = iio_trigger_get(st->trig);
 
-	init_completion(&st->completion);
 
 	ret = devm_iio_triggered_buffer_setup(dev, indio_dev,
 					      &iio_pollfunc_store_time,
-- 
2.34.1


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

* [PATCH 2/2] iio: adc: ad7779: Remove redundant dev_err_probe() after devm_request_irq()
  2026-06-28  7:14   ` [PATCH 1/2] iio: adc: ad7779: Remove unused completion field Moksh Panicker
@ 2026-06-28  7:14     ` Moksh Panicker
  2026-06-28 11:42       ` Joshua Crofts
  2026-06-28 11:41     ` [PATCH 1/2] iio: adc: ad7779: Remove unused completion field Joshua Crofts
  1 sibling, 1 reply; 7+ messages in thread
From: Moksh Panicker @ 2026-06-28  7:14 UTC (permalink / raw)
  To: jic23
  Cc: nuno.sa, Michael.Hennerich, dlechner, joshua.crofts1, linux-iio,
	linux-kernel, skhan, Moksh Panicker

devm_request_irq() already prints an error message on failure via the
IRQ core, so wrapping its return value in dev_err_probe() results in a
duplicate error message. Return the error directly instead.

Suggested-by: Joshua Crofts <joshua.crofts1@gmail.com>
Signed-off-by: Moksh Panicker <mokshpanicker.7@gmail.com>
---
 drivers/iio/adc/ad7779.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/iio/adc/ad7779.c b/drivers/iio/adc/ad7779.c
index c1a99b4c1256..a5b8bfa99a74 100644
--- a/drivers/iio/adc/ad7779.c
+++ b/drivers/iio/adc/ad7779.c
@@ -842,8 +842,7 @@ static int ad7779_setup_without_backend(struct ad7779_state *st, struct iio_dev
 			       IRQF_NO_THREAD | IRQF_NO_AUTOEN, indio_dev->name,
 			       st->trig);
 	if (ret)
-		return dev_err_probe(dev, ret, "request IRQ %d failed\n",
-				     st->spi->irq);
+		return ret;
 
 	ret = devm_iio_trigger_register(dev, st->trig);
 	if (ret)
-- 
2.34.1


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

* Re: [PATCH 1/2] iio: adc: ad7779: Remove unused completion field
  2026-06-28  7:14   ` [PATCH 1/2] iio: adc: ad7779: Remove unused completion field Moksh Panicker
  2026-06-28  7:14     ` [PATCH 2/2] iio: adc: ad7779: Remove redundant dev_err_probe() after devm_request_irq() Moksh Panicker
@ 2026-06-28 11:41     ` Joshua Crofts
  2026-06-28 14:34       ` David Lechner
  1 sibling, 1 reply; 7+ messages in thread
From: Joshua Crofts @ 2026-06-28 11:41 UTC (permalink / raw)
  To: Moksh Panicker
  Cc: jic23, nuno.sa, Michael.Hennerich, dlechner, linux-iio,
	linux-kernel, skhan

On Sun, 28 Jun 2026 07:14:04 +0000
Moksh Panicker <mokshpanicker.7@gmail.com> wrote:

> struct ad7779_state contains a completion field that is initialized
> in ad7779_setup_without_backend() but never waited on or signaled
> anywhere in the driver. Remove the dead code.
> 
> Suggested-by: Joshua Crofts <joshua.crofts1@gmail.com>
> Signed-off-by: Moksh Panicker <mokshpanicker.7@gmail.com>
> ---

If you're sending a patch series, please use a cover letter (if
you're using git send-email, add a cover letter with the
`--cover-letter` flag) where you can describe your changes in
detail, along with additional useful info (testing etc.)

Nevertheless,

Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>

-- 
Kind regards

CJD

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

* Re: [PATCH 2/2] iio: adc: ad7779: Remove redundant dev_err_probe() after devm_request_irq()
  2026-06-28  7:14     ` [PATCH 2/2] iio: adc: ad7779: Remove redundant dev_err_probe() after devm_request_irq() Moksh Panicker
@ 2026-06-28 11:42       ` Joshua Crofts
  0 siblings, 0 replies; 7+ messages in thread
From: Joshua Crofts @ 2026-06-28 11:42 UTC (permalink / raw)
  To: Moksh Panicker
  Cc: jic23, nuno.sa, Michael.Hennerich, dlechner, linux-iio,
	linux-kernel, skhan

On Sun, 28 Jun 2026 07:14:05 +0000
Moksh Panicker <mokshpanicker.7@gmail.com> wrote:

> devm_request_irq() already prints an error message on failure via the
> IRQ core, so wrapping its return value in dev_err_probe() results in a
> duplicate error message. Return the error directly instead.
> 
> Suggested-by: Joshua Crofts <joshua.crofts1@gmail.com>
> Signed-off-by: Moksh Panicker <mokshpanicker.7@gmail.com>
> ---

Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>

-- 
Kind regards

CJD

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

* Re: [PATCH 1/2] iio: adc: ad7779: Remove unused completion field
  2026-06-28 11:41     ` [PATCH 1/2] iio: adc: ad7779: Remove unused completion field Joshua Crofts
@ 2026-06-28 14:34       ` David Lechner
  0 siblings, 0 replies; 7+ messages in thread
From: David Lechner @ 2026-06-28 14:34 UTC (permalink / raw)
  To: Joshua Crofts, Moksh Panicker
  Cc: jic23, nuno.sa, Michael.Hennerich, linux-iio, linux-kernel, skhan

On 6/28/26 6:41 AM, Joshua Crofts wrote:
> On Sun, 28 Jun 2026 07:14:04 +0000
> Moksh Panicker <mokshpanicker.7@gmail.com> wrote:
> 
>> struct ad7779_state contains a completion field that is initialized
>> in ad7779_setup_without_backend() but never waited on or signaled
>> anywhere in the driver. Remove the dead code.
>>
>> Suggested-by: Joshua Crofts <joshua.crofts1@gmail.com>
>> Signed-off-by: Moksh Panicker <mokshpanicker.7@gmail.com>
>> ---
> 
> If you're sending a patch series, please use a cover letter (if
> you're using git send-email, add a cover letter with the
> `--cover-letter` flag) where you can describe your changes in
> detail, along with additional useful info (testing etc.)

Also, please don't send new series or revisions of a series in reply
to other series or previous revisions. It breaks existing workflows
and tooling.

> 
> Nevertheless,
> 
> Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
> 


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

end of thread, other threads:[~2026-06-28 14:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-27 11:22 [PATCH] iio: adc: ad7779: Initialize completion before requesting IRQ Moksh Panicker
2026-06-27 17:26 ` Joshua Crofts
2026-06-28  7:14   ` [PATCH 1/2] iio: adc: ad7779: Remove unused completion field Moksh Panicker
2026-06-28  7:14     ` [PATCH 2/2] iio: adc: ad7779: Remove redundant dev_err_probe() after devm_request_irq() Moksh Panicker
2026-06-28 11:42       ` Joshua Crofts
2026-06-28 11:41     ` [PATCH 1/2] iio: adc: ad7779: Remove unused completion field Joshua Crofts
2026-06-28 14:34       ` David Lechner

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