[PATCH] rtc: rtc-pic32: handle clock enable failure

From: Jiawen Liu

Date: Tue Aug 18 2026 - 09:18:34 EST


Return error from failed clock enable.

Pic32 RTC ignores clk_prepare_enable return before hardware access and
later disables/unprepares clock same pic32 RTC unchecked
clk_prepare_enable.

Check early clk_prepare_enable(pdata->clk) return in pic32_rtc_probe.

Signed-off-by: jiawen <1298662399@xxxxxx>
---
diff --git a/drivers/rtc/rtc-pic32.c b/drivers/rtc/rtc-pic32.c
--- a/drivers/rtc/rtc-pic32.c
+++ b/drivers/rtc/rtc-pic32.c
@@ -325,7 +325,9 @@
if (IS_ERR(pdata->rtc))
return PTR_ERR(pdata->rtc);

- clk_prepare_enable(pdata->clk);
+ ret = clk_prepare_enable(pdata->clk);
+ if (ret)
+ return ret;

pic32_rtc_enable(pdata, 1);