[PATCH] rtc: rtc-cadence: fix clock cleanup ordering
From: Jiawen Liu
Date: Tue Aug 18 2026 - 08:42:08 EST
From: jiawen <1298662399@xxxxxx>
The probe function enables the peripheral clock (pclk) before the
reference clock (ref_clk), and its error path disables ref_clk before
pclk. However, the remove function disables pclk before ref_clk, which
is the reverse order. This asymmetric teardown can leave the clock
framework in an inconsistent state and violates the expected lifecycle
balance. Fix the remove function to disable ref_clk first, then pclk,
matching the probe enable order and the error path cleanup order.
Signed-off-by: jiawen <1298662399@xxxxxx>
---
diff --git a/drivers/rtc/rtc-cadence.c b/drivers/rtc/rtc-cadence.c
--- a/drivers/rtc/rtc-cadence.c
+++ b/drivers/rtc/rtc-cadence.c
@@ -361,8 +361,8 @@
cdns_rtc_alarm_irq_enable(&pdev->dev, 0);
device_init_wakeup(&pdev->dev, false);
+ clk_disable_unprepare(crtc->ref_clk);
clk_disable_unprepare(crtc->pclk);
- clk_disable_unprepare(crtc->ref_clk);
}
#ifdef CONFIG_PM_SLEEP