Skip to contentSkip to conversation

rtc: st-lpc: get IRQ via platform_get_irq()

PATCH Applied Rosen Penev 4 participants 4 messages Jul 14 – Aug 19

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtc: st-lpc: get IRQ via platform_get_irq()

Replace irq_of_parse_and_map() with platform_get_irq(), which resolves the interrupt from pdev->dev.of_node directly and returns a positive IRQ or a negative errno (it never returns 0). Propagate the error on failure instead of the previous open-coded "IRQ missing or invalid" / -EINVAL message, so -EPROBE_DEFER is handled correctly. The rtc->irq field is a signed short, so the negative error code is preserved.

np is still used by of_property_read_u32() for "st,lpc-mode", so it is not removed.

Built for ARM (multi_v7_defconfig + CONFIG_RTC_DRV_ST_LPC) with LLVM=1; drivers/rtc/rtc-st-lpc.o compiles cleanly.

Assisted-by opencode:hy3-free
---
 drivers/rtc/rtc-st-lpc.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/rtc/rtc-st-lpc.c +3 -6
index c6d4522411b3..ae79ddf24f37 100644
@@ -18,7 +18,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/of.h>
-#include <linux/of_irq.h>
 #include <linux/platform_device.h>
 #include <linux/rtc.h>
 
@@ -212,11 +211,9 @@ static int st_rtc_probe(struct platform_device *pdev)
 	if (IS_ERR(rtc->ioaddr))
 		return PTR_ERR(rtc->ioaddr);
 
-	rtc->irq = irq_of_parse_and_map(np, 0);
-	if (!rtc->irq) {
-		dev_err(&pdev->dev, "IRQ missing or invalid\n");
-		return -EINVAL;
-	}
+	rtc->irq = platform_get_irq(pdev, 0);
+	if (rtc->irq < 0)
+		return rtc->irq;
 
 	ret = devm_request_irq(&pdev->dev, rtc->irq, st_rtc_handler,
 			       IRQF_NO_AUTOEN, pdev->name, rtc);
Signature · 1 line
2.55.0
#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 7 lines

Replace irq_of_parse_and_map() with platform_get_irq(), which resolves the interrupt from pdev->dev.of_node directly and returns a positive IRQ or a negative errno (it never returns 0). Propagate the error on failure instead of the previous open-coded "IRQ missing or invalid" / -EINVAL message, so -EPROBE_DEFER is handled correctly. The rtc->irq field is a signed short, so the negative error code is preserved.

Quoted 8 lines

np is still used by of_property_read_u32() for "st,lpc-mode", so it is not removed.

Built for ARM (multi_v7_defconfig + CONFIG_RTC_DRV_ST_LPC) with LLVM=1; drivers/rtc/rtc-st-lpc.o compiles cleanly.

Assisted-by opencode:hy3-free

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Rosen Penev
Quoted 36 lines · Rosen Penev

Replace irq_of_parse_and_map() with platform_get_irq(), which resolves the interrupt from pdev->dev.of_node directly and returns a positive IRQ or a negative errno (it never returns 0). Propagate the error on failure instead of the previous open-coded "IRQ missing or invalid" / -EINVAL message, so -EPROBE_DEFER is handled correctly. The rtc->irq field is a signed short, so the negative error code is preserved.

np is still used by of_property_read_u32() for "st,lpc-mode", so it is not removed.

Built for ARM (multi_v7_defconfig + CONFIG_RTC_DRV_ST_LPC) with LLVM=1; drivers/rtc/rtc-st-lpc.o compiles cleanly.

Assisted-by opencode:hy3-free
---
 drivers/rtc/rtc-st-lpc.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/rtc/rtc-st-lpc.c +0 -2
index c6d4522411b3..ae79ddf24f37 100644
@@ -18,7 +18,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/of.h>
-#include <linux/of_irq.h>
 #include <linux/platform_device.h>
 #include <linux/rtc.h>
 
@@ -212,11 +211,9 @@ static int st_rtc_probe(struct platform_device *pdev)
 	if (IS_ERR(rtc->ioaddr))
 		return PTR_ERR(rtc->ioaddr);
 
-	rtc->irq = irq_of_parse_and_map(np, 0);

drivers/rtc/rtc-st-lpc.c static int st_rtc_probe(struct platform_device *pdev) · line 219

Quoted 10 lines
drivers/rtc/rtc-st-lpc.c +3 -4
-	if (!rtc->irq) {
-		dev_err(&pdev->dev, "IRQ missing or invalid\n");
-		return -EINVAL;
-	}
+	rtc->irq = platform_get_irq(pdev, 0);
+	if (rtc->irq < 0)
+		return rtc->irq;
 
 	ret = devm_request_irq(&pdev->dev, rtc->irq, st_rtc_handler,
 			       IRQF_NO_AUTOEN, pdev->name, rtc);

Hi Rosen

Thanks
Patrice

maintainer Applied
#3 lore raw
In reply to Rosen Penev
Quoted 8 lines · Rosen Penev

Replace irq_of_parse_and_map() with platform_get_irq(), which resolves the interrupt from pdev->dev.of_node directly and returns a positive IRQ or a negative errno (it never returns 0). Propagate the error on failure instead of the previous open-coded "IRQ missing or invalid" / -EINVAL message, so -EPROBE_DEFER is handled correctly. The rtc->irq field is a signed short, so the negative error code is preserved.

[...]

Applied, thanks!

[1/1] rtc: st-lpc: get IRQ via platform_get_irq()

      https://git.kernel.org/abelloni/c/da5e8713aee5

Best regards,

Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com