Linux Watchdog driver development
 help / color / mirror / Atom feed
* [PATCH] Watchdog: fix pretimeout noop governor logging and description
@ 2026-06-16 17:19 Lorenzo Egidio
  2026-06-16 17:20 ` sashiko-bot
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Lorenzo Egidio @ 2026-06-16 17:19 UTC (permalink / raw)
  To: linux-watchdog, linux, wim; +Cc: linux-kernel, Lorenzo Egidio

Overview
This review is dedicated to a pretimeout governor implementation of Linux kernel watchdog ("noop"). The overall module organization and the registration mechanism are done rightly and in accordance with the kernel standards. But, two points were noticed that could result in either compilation errors or difficulties in maintainability.
1. Potential problem: pr_alert usage with the wdd->id
Within the callback function:
static void pretimeout_noop(struct watchdog_device *wdd) { pr_alert("watchdog%d: pretimeout event\n", wdd->id); }
Problem
The id field of the struct watchdog_device is not ensured to be present in all Linux kernel versions. Actually, in many recent kernel versions, this field is either missing or not exposed in the public structure API.
Consequence
Compilation may fail with the following error at compile time:error: 'struct watchdog_device' has no member named 'id'
Portability of the code to different kernel versions is lessened as it depends on the details of the internal structure.

Suggestions
Do not directly access wdd->id. It is better to use a general message or a stable field which is safe across versions if available.
An example of a safe alternative:
pr_alert("watchdog: pretimeout event\n");
2. Mismatch in MODULE_DESCRIPTION
The present module declares:
MODULE_DESCRIPTION("Panic watchdog pretimeout governor");
Problem
There is a difference between the module description and the very name of the governor:
.name = "noop"
The code clearly states a "noop" governor, but the description talks about a "panic" governor, thereby causing misunderstanding.
Result
Developers and maintainers get confused
The module metadata is not correctly described
There is a decrease in clarity in logs and documentation

Suggestion
Correct the module description to be in line with the actual operation of the implementation.
Example:
MODULE_DESCRIPTION("Noop watchdog pretimeout governor");
Conclusion
The implementation is good structurally and it fits well with the Linux kernel watchdog governor framework. On the other hand, the usage of wdd->id could result in the incompatibility problem with the different kernel versions and the module metadata carries a description inconsistency that has to be fixed for the better clarity and maintainability.

Signed-off-by: Lorenzo Egidio <lorenzoegidioms@gmail.com>
---
 drivers/watchdog/pretimeout_noop.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/pretimeout_noop.c b/drivers/watchdog/pretimeout_noop.c
index 74ec02b9f..ddb5192fb 100644
--- a/drivers/watchdog/pretimeout_noop.c
+++ b/drivers/watchdog/pretimeout_noop.c
@@ -17,7 +17,7 @@
  */
 static void pretimeout_noop(struct watchdog_device *wdd)
 {
-	pr_alert("watchdog%d: pretimeout event\n", wdd->id);
+	pr_alert("watchdog%d: pretimeout event\n");
 }
 
 static struct watchdog_governor watchdog_gov_noop = {
@@ -38,5 +38,5 @@ module_init(watchdog_gov_noop_register);
 module_exit(watchdog_gov_noop_unregister);
 
 MODULE_AUTHOR("Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>");
-MODULE_DESCRIPTION("Panic watchdog pretimeout governor");
+MODULE_DESCRIPTION("Noop watchdog pretimeout governor");
 MODULE_LICENSE("GPL");
-- 
2.51.0


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

end of thread, other threads:[~2026-06-17  4:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-16 17:19 [PATCH] Watchdog: fix pretimeout noop governor logging and description Lorenzo Egidio
2026-06-16 17:20 ` sashiko-bot
2026-06-16 18:44 ` Guenter Roeck
2026-06-17  4:30 ` kernel test robot
2026-06-17  4:34 ` kernel test robot

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