Re: [PATCH] iio: adc: ad7779: Initialize completion before requesting IRQ

From: Joshua Crofts

Date: Sat Jun 27 2026 - 13:26:51 EST


On Sat, 27 Jun 2026 11:22:05 +0000
Moksh Panicker <mokshpanicker.7@xxxxxxxxx> 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@xxxxxxxxxxxxxxx
> Signed-off-by: Moksh Panicker <mokshpanicker.7@xxxxxxxxx>
> ---
> 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