Convert the threaded IRQ registration to devm_request_threaded_irq() so
that the probe and remove paths can drop manual freeing of irqs.
No functionality change.
Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
---
drivers/iio/accel/sca3000.c | 25 ++++++++-----------------
1 file changed, 8 insertions(+), 17 deletions(-)
diff --git a/drivers/iio/accel/sca3000.c b/drivers/iio/accel/sca3000.c
index 43373c798714..e270f445bb35 100644
--- a/drivers/iio/accel/sca3000.c
+++ b/drivers/iio/accel/sca3000.c
@@ -1470,34 +1470,27 @@ static int sca3000_probe(struct spi_device *spi)
return ret;
if (spi->irq) {
- ret = request_threaded_irq(spi->irq,
- NULL,
- &sca3000_event_handler,
- IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
- "sca3000",
- indio_dev);
+ ret = devm_request_threaded_irq(dev, spi->irq, NULL,
+ &sca3000_event_handler,
+ IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+ "sca3000",
+ indio_dev);
if (ret)
return ret;
}
ret = sca3000_clean_setup(st);
if (ret)
- goto error_free_irq;
+ return ret;
ret = sca3000_print_rev(indio_dev);
if (ret)
- goto error_free_irq;
+ return ret;
ret = iio_device_register(indio_dev);
if (ret)
- goto error_free_irq;
+ return ret;
return 0;
-
-error_free_irq:
- if (spi->irq)
- free_irq(spi->irq, indio_dev);
-
- return ret;
}
static int sca3000_stop_all_interrupts(struct sca3000_state *st)
@@ -1527,8 +1520,6 @@ static void sca3000_remove(struct spi_device *spi)
/* Must ensure no interrupts can be generated after this! */
sca3000_stop_all_interrupts(st);
- if (spi->irq)
- free_irq(spi->irq, indio_dev);
}
static const struct spi_device_id sca3000_id[] = {
--
2.47.3
On Thu, Feb 05, 2026 at 05:12:08AM -0800, Harshit Mogalapalli wrote: > Convert the threaded IRQ registration to devm_request_threaded_irq() so > that the probe and remove paths can drop manual freeing of irqs. > > No functionality change. ... > -error_free_irq: > - if (spi->irq) > - free_irq(spi->irq, indio_dev); > - > - return ret; ... > - if (spi->irq) > - free_irq(spi->irq, indio_dev); Do we need an irq member to be in the struct after this patch? -- With Best Regards, Andy Shevchenko
Hi Andy, On 05/02/26 21:53, Andy Shevchenko wrote: > On Thu, Feb 05, 2026 at 05:12:08AM -0800, Harshit Mogalapalli wrote: >> Convert the threaded IRQ registration to devm_request_threaded_irq() so >> that the probe and remove paths can drop manual freeing of irqs. >> >> No functionality change. > > ... > Thanks for the reviews! >> -error_free_irq: >> - if (spi->irq) >> - free_irq(spi->irq, indio_dev); >> - >> - return ret; > > ... > >> - if (spi->irq) >> - free_irq(spi->irq, indio_dev); > > Do we need an irq member to be in the struct after this patch? I probably didn't understand that question fully. we still have a call to ret = devm_request_threaded_irq(dev, spi->irq, NULL,...) so we can't relaly get rid of the irq member I think, did I understand your question right ? Thanks, Harshit >
On Thu, Feb 05, 2026 at 10:09:45PM +0530, Harshit Mogalapalli wrote: > On 05/02/26 21:53, Andy Shevchenko wrote: > > On Thu, Feb 05, 2026 at 05:12:08AM -0800, Harshit Mogalapalli wrote: ... > > > - if (spi->irq) > > > - free_irq(spi->irq, indio_dev); > > > > Do we need an irq member to be in the struct after this patch? > > I probably didn't understand that question fully. > > we still have a call to ret = devm_request_threaded_irq(dev, spi->irq, > NULL,...) so we can't relaly get rid of the irq member I think, > did I understand your question right ? Yes. But now I realised that this is the external structure, and not the one the driver defines. Sorry for the noise. -- With Best Regards, Andy Shevchenko
On 05/02/26 22:15, Andy Shevchenko wrote: > On Thu, Feb 05, 2026 at 10:09:45PM +0530, Harshit Mogalapalli wrote: >> On 05/02/26 21:53, Andy Shevchenko wrote: >>> On Thu, Feb 05, 2026 at 05:12:08AM -0800, Harshit Mogalapalli wrote: > > ... > >>>> - if (spi->irq) >>>> - free_irq(spi->irq, indio_dev); >>> >>> Do we need an irq member to be in the struct after this patch? >> >> I probably didn't understand that question fully. >> >> we still have a call to ret = devm_request_threaded_irq(dev, spi->irq, >> NULL,...) so we can't relaly get rid of the irq member I think, >> did I understand your question right ? > > Yes. But now I realised that this is the external structure, and not the one > the driver defines. Sorry for the noise. > Np, yes this is part of spi_device a more central structure. Thanks for checking! Regards, Harshit
© 2016 - 2026 Red Hat, Inc.