Linux RTC
 help / color / mirror / Atom feed
* [PATCH] rtc: ds1307: use IS_REACHABLE(CONFIG_WATCHDOG_CORE) for DS1388 watchdog
@ 2026-12-04  2:19 Pengpeng Hou
  2026-12-04  2:24 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-12-04  2:19 UTC (permalink / raw)
  To: Alexandre Belloni; +Cc: linux-rtc, Pengpeng Hou

The DS1388 watchdog operations and registration in the DS1307 driver are
guarded by the built-in watchdog core symbol. They disappear when both
the RTC driver and watchdog core are modules.

Make both guards test reachability. Keep the existing DS1388 model
check.

The issue was found by our static-analysis tool and manually reviewed.

Fixes: fd90d48db037 ("rtc: ds1307: add support for watchdog timer on ds1388")
Signed-off-by: Pengpeng Hou <hppiscas@163.com>
---
The original patch was prepared with Gemini. Codex assisted with this
review and revision (Assisted-by: gpt 5).
Built rtc-ds1307.o on x86-64 with GCC 11.4 and W=1
(CONFIG_RTC_DRV_DS1307=m, CONFIG_WATCHDOG_CORE=m). No runtime or
hardware test was performed.

 drivers/rtc/rtc-ds1307.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 8ab28cc2f1815d771fa5878cc207958c6a748ca0..d2f05719a7305171691d9d2c0bf32ddbdb4287d6 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -890,7 +890,7 @@ static int m41txx_rtc_set_offset(struct device *dev, long offset)
 				  ctrl_reg);
 }
 
-#ifdef CONFIG_WATCHDOG_CORE
+#if IS_REACHABLE(CONFIG_WATCHDOG_CORE)
 static int ds1388_wdt_start(struct watchdog_device *wdt_dev)
 {
 	struct ds1307 *ds1307 = watchdog_get_drvdata(wdt_dev);
@@ -1819,7 +1819,7 @@ static void ds1307_clks_register(struct ds1307 *ds1307)
 
 #endif /* CONFIG_COMMON_CLK */
 
-#ifdef CONFIG_WATCHDOG_CORE
+#if IS_REACHABLE(CONFIG_WATCHDOG_CORE)
 static const struct watchdog_info ds1388_wdt_info = {
 	.options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
 	.identity = "DS1388 watchdog",

base-commit: d06ce6f1eb5eeffd4ebcfde345dc34a98131d106


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-04  2:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04  2:19 [PATCH] rtc: ds1307: use IS_REACHABLE(CONFIG_WATCHDOG_CORE) for DS1388 watchdog Pengpeng Hou
2026-12-04  2:24 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox