[PATCH next 2/4] iio: sca3000: switch IRQ handling to devm helpers

Harshit Mogalapalli posted 4 patches 1 week, 2 days ago
There is a newer version of this series
[PATCH next 2/4] iio: sca3000: switch IRQ handling to devm helpers
Posted by Harshit Mogalapalli 1 week, 2 days ago
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>
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
---
 drivers/iio/accel/sca3000.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/iio/accel/sca3000.c b/drivers/iio/accel/sca3000.c
index afe6ef61a53b..0210c716cf38 100644
--- a/drivers/iio/accel/sca3000.c
+++ b/drivers/iio/accel/sca3000.c
@@ -1473,8 +1473,7 @@ static int sca3000_probe(struct spi_device *spi)
 		return ret;
 
 	if (spi->irq) {
-		ret = request_threaded_irq(spi->irq,
-					   NULL,
+		ret = devm_request_threaded_irq(dev, spi->irq, NULL,
 					   &sca3000_event_handler,
 					   IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
 					   "sca3000",
@@ -1484,23 +1483,17 @@ static int sca3000_probe(struct spi_device *spi)
 	}
 	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)
@@ -1530,8 +1523,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.50.1
Re: [PATCH next 2/4] iio: sca3000: switch IRQ handling to devm helpers
Posted by David Lechner 1 week, 1 day ago
On 1/30/26 3:43 PM, 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.
> 


...

> @@ -1484,23 +1483,17 @@ static int sca3000_probe(struct spi_device *spi)
>  	}
>  	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;
This can `return iio_device_register();` directly now.
Re: [PATCH next 2/4] iio: sca3000: switch IRQ handling to devm helpers
Posted by Harshit Mogalapalli 1 week, 1 day ago
Hi David,



On 01/02/26 00:51, David Lechner wrote:
> On 1/30/26 3:43 PM, 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.
>>
> 
> 
> ...
> 
>> @@ -1484,23 +1483,17 @@ static int sca3000_probe(struct spi_device *spi)
>>   	}
>>   	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;
> This can `return iio_device_register();` directly now.

Thanks for the review and comments! I agree, it could have been simplified.

I am working on a v2 now. Will address it, in v2 basically the 
iio_device_register() --> devm_iio_device_register() conversion is done 
in last patch so we don't have this problem, so it kind of gets 
auto-resolved in v2.

Thanks,
Harshit
Re: [PATCH next 2/4] iio: sca3000: switch IRQ handling to devm helpers
Posted by Jonathan Cameron 1 week, 1 day ago
On Fri, 30 Jan 2026 13:43:09 -0800
Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com> 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.
> 
> Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Hi Harshit,

Minor formatting update needed. See inline.

Thanks,

Jonathan

> ---
>  drivers/iio/accel/sca3000.c | 17 ++++-------------
>  1 file changed, 4 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/iio/accel/sca3000.c b/drivers/iio/accel/sca3000.c
> index afe6ef61a53b..0210c716cf38 100644
> --- a/drivers/iio/accel/sca3000.c
> +++ b/drivers/iio/accel/sca3000.c
> @@ -1473,8 +1473,7 @@ static int sca3000_probe(struct spi_device *spi)
>  		return ret;
>  
>  	if (spi->irq) {
> -		ret = request_threaded_irq(spi->irq,
> -					   NULL,
> +		ret = devm_request_threaded_irq(dev, spi->irq, NULL,
>  					   &sca3000_event_handler,
Update the indent to keep these after the (
That is:
		ret = devm_request_threaded_irq(dev, spi->irq, NULL,
 						&sca3000_event_handler,
						IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
						"sca3000",
etc



>  					   IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
>  					   "sca3000",
> @@ -1484,23 +1483,17 @@ static int sca3000_probe(struct spi_device *spi)
>  	}
>  	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)
> @@ -1530,8 +1523,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[] = {
Re: [PATCH next 2/4] iio: sca3000: switch IRQ handling to devm helpers
Posted by Harshit Mogalapalli 1 week, 1 day ago
Hi Jonathan,


On 31/01/26 22:00, Jonathan Cameron wrote:
>>   
>>   	if (spi->irq) {
>> -		ret = request_threaded_irq(spi->irq,
>> -					   NULL,
>> +		ret = devm_request_threaded_irq(dev, spi->irq, NULL,
>>   					   &sca3000_event_handler,
> Update the indent to keep these after the (
> That is:
> 		ret = devm_request_threaded_irq(dev, spi->irq, NULL,
>   						&sca3000_event_handler,
> 						IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
> 						"sca3000",
> etc
> 

Oh, right, I should have indented it properly, sorry about that. I 
thought checkpatch was catching these. Will fix this in a next version. 
Thanks for spotting this.

Regards,
Harshit