iio: adc: ad7779: Initialize completion before requesting IRQ
Subsystems (3)
PATCH 1/1 iio: adc: ad7779: Initialize completion before requesting IRQ
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.
--- drivers/iio/adc/ad7779.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/adc/ad7779.c +2 -2
@@ -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,
Signature · 1 line
2.34.1
Quoted 3 lines · On Sat, 27 Jun 2026 11:22:05 +0000 Moksh Panicker <[email protected]>…
init_completion()is called afterdevm_request_irq()inad7779_setup_trigger(). If the IRQ fires beforeinit_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.
Quoted 15 lines
Move
init_completion()beforedevm_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")Signed-off-by Moksh Panicker <[email protected]>--- drivers/iio/adc/ad7779.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/iio/adc/ad7779.c +0
-0
drivers/iio/adc/ad7779.c static int ad7779_setup_without_backend(struct ad7779_state *st, struct iio_dev · line 841
Quoted 4 lines
drivers/iio/adc/ad7779.c +1
-0@@ -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.
drivers/iio/adc/ad7779.c static int ad7779_setup_without_backend(struct ad7779_state *st, struct iio_dev · line 845
Quoted 4 lines
drivers/iio/adc/ad7779.c +1
-0+ 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.
Signature · 3 lines
Kind regards CJD
PATCH 1/2 iio: adc: ad7779: Remove unused completion field
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.
--- drivers/iio/adc/ad7779.c | 2 -- 1 file changed, 2 deletions(-)
drivers/iio/adc/ad7779.c +0 -2
@@ -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,
Signature · 1 line
2.34.1
PATCH 2/2 iio: adc: ad7779: Remove redundant dev_err_probe() after devm_request_irq()
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.
--- drivers/iio/adc/ad7779.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iio/adc/ad7779.c +1 -2
@@ -842,8 +842,7 @@ static int ad7779_setup_without_backend(struct ad7779_state *st, struct iio_devIRQF_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)
Signature · 1 line
2.34.1
Re: [PATCH 2/2] iio: adc: ad7779: Remove redundant dev_err_probe() after devm_request_irq()
Quoted 7 lines · On Sun, 28 Jun 2026 07:14:05 +0000 Moksh Panicker <[email protected]>…
devm_request_irq()already prints an error message on failure via the IRQ core, so wrapping its return value indev_err_probe()results in a duplicate error message. Return the error directly instead.Suggested-by Joshua Crofts <[email protected]>Signed-off-by Moksh Panicker <[email protected]>---
Signature · 3 lines
Kind regards CJD
Re: [PATCH 1/2] iio: adc: ad7779: Remove unused completion field
In reply to Moksh PanickerQuoted 7 lines · On Sun, 28 Jun 2026 07:14:04 +0000 Moksh Panicker <[email protected]>…
struct
ad7779_statecontains a completion field that is initialized inad7779_setup_without_backend()but never waited on or signaled anywhere in the driver. Remove the dead code.Suggested-by Joshua Crofts <[email protected]>Signed-off-by Moksh Panicker <[email protected]>---
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,
Signature · 3 lines
Kind regards CJD
David Lechner
reviewerRe: [PATCH 1/2] iio: adc: ad7779: Remove unused completion field
Quoted 7 lines · Joshua Crofts
Quoted 4 lines · On Sun, 28 Jun 2026 07:14:04 +0000 Moksh Panicker <[email protected]>…
struct
ad7779_statecontains a completion field that is initialized inad7779_setup_without_backend()but never waited on or signaled anywhere in the driver. Remove the dead code.
Quoted 8 lines
Quoted 3 lines
Suggested-by Joshua Crofts <[email protected]>Signed-off-by Moksh Panicker <[email protected]>---
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-letterflag) 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.
Quoted 5 lines
Nevertheless,
Reviewed-by Joshua Crofts <[email protected]>