Skip to contentSkip to conversation

rtc: rzn1: clear interrupts on remove

PATCH Applied Wolfram Sang 2 participants 4 messages Mar 12, 2025 – Apr 8, 2025

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

PATCH v2 1/1 rtc: rzn1: clear interrupts on remove

It is good practice to clear running interrupts before removing the driver. This is not really a bugfix because on current systems RuntimePM will disable the module clock, so interrupts won't be initiated. The dependency on that behaviour is subtle, though. Better be self-contained and clean up when removing.

---

Change since v1: fix build failure by adding the 'rtc' variable. Build and tested on Renesas RZ/N1D.

 drivers/rtc/rtc-rzn1.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/rtc/rtc-rzn1.c +5 -0
index eeb9612a666f..3c2861983ff1 100644
@@ -444,6 +444,11 @@ static int rzn1_rtc_probe(struct platform_device *pdev)
 
 static void rzn1_rtc_remove(struct platform_device *pdev)
 {
+	struct rzn1_rtc *rtc = platform_get_drvdata(pdev);
+
+	/* Disable all interrupts */
+	writel(0, rtc->base + RZN1_RTC_CTL1);
+
 	pm_runtime_put(&pdev->dev);
 }
 
Signature · 1 line
2.47.2
maintainer Applied
#1 lore raw
Quoted 8 lines · Wolfram Sang

It is good practice to clear running interrupts before removing the driver. This is not really a bugfix because on current systems RuntimePM will disable the module clock, so interrupts won't be initiated. The dependency on that behaviour is subtle, though. Better be self-contained and clean up when removing.

[...]

Applied, thanks!

[1/1] rtc: rzn1: clear interrupts on remove

      https://git.kernel.org/abelloni/c/0bddd060a6a3

Best regards,

Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw
In reply to Wolfram Sang
Quoted 2 lines · Wolfram Sang

It is good practice to clear running interrupts before removing the driver. This is not really a bugfix because on current systems RuntimePM

This is not completely true, most of the drivers would leave the interrupt enabled after removing the driver because it can still power on a device.

Quoted 32 lines

will disable the module clock, so interrupts won't be initiated. The dependency on that behaviour is subtle, though. Better be self-contained and clean up when removing.

---

Change since v1: fix build failure by adding the 'rtc' variable. Build and tested on Renesas RZ/N1D.

 drivers/rtc/rtc-rzn1.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/rtc/rtc-rzn1.c +5 -0
index eeb9612a666f..3c2861983ff1 100644
@@ -444,6 +444,11 @@ static int rzn1_rtc_probe(struct platform_device *pdev)
 
 static void rzn1_rtc_remove(struct platform_device *pdev)
 {
+	struct rzn1_rtc *rtc = platform_get_drvdata(pdev);
+
+	/* Disable all interrupts */
+	writel(0, rtc->base + RZN1_RTC_CTL1);
+
 	pm_runtime_put(&pdev->dev);
 }
 
Signature · 1 line
2.47.2
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#3 lore raw
Quoted 7 lines · Alexandre Belloni
Quoted 2 lines · Wolfram Sang

It is good practice to clear running interrupts before removing the driver. This is not really a bugfix because on current systems RuntimePM

This is not completely true, most of the drivers would leave the interrupt enabled after removing the driver because it can still power on a device.

Ah, okay. Good to know that scenario as well. Thanks.