Skip to contentSkip to conversation

watchdog: ulp_wdog: guard reset_cpu with condition check

PATCH In review Peng Fan (OSS) 2 participants 3 messages Apr 6, 2023 – Apr 12, 2023 Watchdog device drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 watchdog: ulp_wdog: guard reset_cpu with condition check

From: Peng Fan <[email protected]>

There will be build error if CONFIG_SYSRESET is enabled, so guard the reset_cpu with condition check here

---
 drivers/watchdog/ulp_wdog.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/watchdog/ulp_wdog.c +2 -0
index c21aa3af55f..0eea04ed2c6 100644
@@ -122,6 +122,7 @@ void hw_watchdog_init(void)
 	ulp_watchdog_init(wdog, CONFIG_WATCHDOG_TIMEOUT_MSECS);
 }
 
+#if !CONFIG_IS_ENABLED(SYSRESET)
 void reset_cpu(void)
 {
 	struct wdog_regs *wdog = (struct wdog_regs *)WDOG_BASE_ADDR;
@@ -159,6 +160,7 @@ void reset_cpu(void)
 
 	while (1);
 }
+#endif
 
 static int ulp_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
 {
Signature · 1 line
2.36.0
#1 lore raw
Quoted 23 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

There will be build error if CONFIG_SYSRESET is enabled, so guard the reset_cpu with condition check here

---
  drivers/watchdog/ulp_wdog.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/watchdog/ulp_wdog.c +1 -0
index c21aa3af55f..0eea04ed2c6 100644
@@ -122,6 +122,7 @@ void hw_watchdog_init(void)
  	ulp_watchdog_init(wdog, CONFIG_WATCHDOG_TIMEOUT_MSECS);
  }
 
+#if !CONFIG_IS_ENABLED(SYSRESET)
  void reset_cpu(void)
  {
  	struct wdog_regs *wdog = (struct wdog_regs *)WDOG_BASE_ADDR;

drivers/watchdog/ulp_wdog.c void reset_cpu(void) · line 163

Quoted 4 lines
drivers/watchdog/ulp_wdog.c +1 -0
@@ -159,6 +160,7 @@ void reset_cpu(void)
 
  	while (1);
  }
+#endif

Hmmm, isn't it possible to move reset_cpu() out of this file into some other (platform?) directly? IMHO this API does not really belong into the watchdog infrastructure.

Thanks,
Stefan

author
#2 lore raw
Quoted 22 lines · Stefan Roese
Quoted 21 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

There will be build error if CONFIG_SYSRESET is enabled, so guard the reset_cpu with condition check here

---
  drivers/watchdog/ulp_wdog.c | 2 ++

  1 file changed, 2 insertions(+)
drivers/watchdog/ulp_wdog.c +1 -0
index c21aa3af55f..0eea04ed2c6 100644
@@ -122,6 +122,7 @@ void hw_watchdog_init(void)
       ulp_watchdog_init(wdog, CONFIG_WATCHDOG_TIMEOUT_MSECS);
   }
+#if !CONFIG_IS_ENABLED(SYSRESET)
   void reset_cpu(void)
   {
       struct wdog_regs *wdog = (struct wdog_regs *)WDOG_BASE_ADDR;
Quoted 8 lines

drivers/watchdog/ulp_wdog.c void reset_cpu(void) · line 162

Quoted 4 lines
drivers/watchdog/ulp_wdog.c +1 -0
@@ -159,6 +160,7 @@ void reset_cpu(void)
       while (1);
   }
+#endif

Hmmm, isn't it possible to move reset_cpu() out of this file into some other (platform?) directly? IMHO this API does not really belong into the watchdog infrastructure.

But here reset_cpu use wdog to trigger reset. i.MX7ULP, i.MX93 both use this driver. It is possible to move it out, but means the macro definition also needs a copy or else.

Thanks,
Peng.

Quoted 3 lines

Thanks,
Stefan