Skip to contentSkip to conversation

drivers/i2c/busses/i2c-imx.c: Use with resource management to register interrupts

PATCH In review lizhe 2 participants 2 messages Dec 10, 2021

Subsystems (3)
lore
Share & tools
lore

lizhe

author
#0 lore raw

PATCH 1/1 drivers/i2c/busses/i2c-imx.c: Use with resource management to register interrupts

In the probe function, used devm_request_threaded_irq instead of request_threaded_irq, make full use of the resource management function provided by the kernel

---
 drivers/i2c/busses/i2c-imx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/i2c/busses/i2c-imx.c +1 -2
index 3576b63a6c03..3e99827b2720 100644
@@ -1426,7 +1426,7 @@ static int i2c_imx_probe(struct platform_device *pdev)
 		goto rpm_disable;
 
 	/* Request IRQ */
-	ret = request_threaded_irq(irq, i2c_imx_isr, NULL, IRQF_SHARED,
+	ret = devm_request_threaded_irq(irq, i2c_imx_isr, NULL, IRQF_SHARED,
 				   pdev->name, i2c_imx);
 	if (ret) {
 		dev_err(&pdev->dev, "can't claim irq %d\n", irq);
@@ -1472,7 +1472,6 @@ static int i2c_imx_probe(struct platform_device *pdev)
 
 clk_notifier_unregister:
 	clk_notifier_unregister(i2c_imx->clk, &i2c_imx->clk_change_nb);
-	free_irq(irq, i2c_imx);
 rpm_disable:
 	pm_runtime_put_noidle(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
Signature · 1 line
2.25.1
#1 lore raw

Hello lizhe,

Quoted 3 lines · lizhe

In the probe function, used devm_request_threaded_irq instead of request_threaded_irq, make full use of the resource management function provided by the kernel

See e50e4f0b85be ("i2c: imx: Fix external abort on interrupt in exit paths") for why this isn't a safe thing to do here. Given that this is the third time, I think, this was suggested, you may want to instead patch in a comment explaining why we _don't_ use devm_request_threaded_irq here..

Cheers,
Ahmad

Quoted 28 lines
---
 drivers/i2c/busses/i2c-imx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/i2c/busses/i2c-imx.c +1 -2
index 3576b63a6c03..3e99827b2720 100644
@@ -1426,7 +1426,7 @@ static int i2c_imx_probe(struct platform_device *pdev)
 		goto rpm_disable;
 
 	/* Request IRQ */
-	ret = request_threaded_irq(irq, i2c_imx_isr, NULL, IRQF_SHARED,
+	ret = devm_request_threaded_irq(irq, i2c_imx_isr, NULL, IRQF_SHARED,
 				   pdev->name, i2c_imx);
 	if (ret) {
 		dev_err(&pdev->dev, "can't claim irq %d\n", irq);
@@ -1472,7 +1472,6 @@ static int i2c_imx_probe(struct platform_device *pdev)
 
 clk_notifier_unregister:
 	clk_notifier_unregister(i2c_imx->clk, &i2c_imx->clk_change_nb);
-	free_irq(irq, i2c_imx);
 rpm_disable:
 	pm_runtime_put_noidle(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |