[PATCH] selftests/watchdog: fix WDIOC_GETSTATUS flag decoding

Chun-Cheng Chang posted 1 patch 1 month ago
.../selftests/watchdog/watchdog-test.c        | 24 +++++++++++--------
1 file changed, 14 insertions(+), 10 deletions(-)
[PATCH] selftests/watchdog: fix WDIOC_GETSTATUS flag decoding
Posted by Chun-Cheng Chang 1 month ago
The wdiof_status table decodes WDIOC_GETSTATUS results and
watchdog_info.options, both of which use WDIOF_* flags.

It incorrectly contains WDIOS_* flags, which are only valid for
WDIOC_SETOPTIONS. Since the values overlap, status bits can be
reported as enable, disable, or temperature-panic operations.

Replace the WDIOS_* entries with the missing WDIOF_* status flags
and use WDIOF_UNKNOWN consistently.

Fixes: ac7e8d3e4a7c ("selftests/watchdog: add support for WDIOC_GETSTATUS")
Signed-off-by: Chun-Cheng Chang <frank0988855428@gmail.com>
---
 .../selftests/watchdog/watchdog-test.c        | 24 +++++++++++--------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/tools/testing/selftests/watchdog/watchdog-test.c b/tools/testing/selftests/watchdog/watchdog-test.c
index 4f09c5db0c7f..3802649b2944 100644
--- a/tools/testing/selftests/watchdog/watchdog-test.c
+++ b/tools/testing/selftests/watchdog/watchdog-test.c
@@ -106,24 +106,28 @@ struct wdiof_status {
 	const char *status_str;
 };
 
-#define WDIOF_NUM_STATUS 8
+#define WDIOF_NUM_STATUS 12
 
 static const struct wdiof_status wdiof_status[WDIOF_NUM_STATUS] = {
-	{WDIOF_SETTIMEOUT,  "Set timeout (in seconds)"},
-	{WDIOF_MAGICCLOSE,  "Supports magic close char"},
-	{WDIOF_PRETIMEOUT,  "Pretimeout (in seconds), get/set"},
-	{WDIOF_ALARMONLY,  "Watchdog triggers a management or other external alarm not a reboot"},
-	{WDIOF_KEEPALIVEPING,  "Keep alive ping reply"},
-	{WDIOS_DISABLECARD,  "Turn off the watchdog timer"},
-	{WDIOS_ENABLECARD,  "Turn on the watchdog timer"},
-	{WDIOS_TEMPPANIC,  "Kernel panic on temperature trip"},
+	{WDIOF_OVERHEAT, "Reset due to CPU overheat"},
+	{WDIOF_FANFAULT, "Fan failed"},
+	{WDIOF_EXTERN1, "External relay 1"},
+	{WDIOF_EXTERN2, "External relay 2"},
+	{WDIOF_POWERUNDER, "Power bad/power fault"},
+	{WDIOF_CARDRESET, "Card previously reset the CPU"},
+	{WDIOF_POWEROVER, "Power over voltage"},
+	{WDIOF_SETTIMEOUT, "Set timeout (in seconds)"},
+	{WDIOF_MAGICCLOSE, "Supports magic close char"},
+	{WDIOF_PRETIMEOUT, "Pretimeout (in seconds), get/set"},
+	{WDIOF_ALARMONLY, "Watchdog triggers a management or other external alarm not a reboot"},
+	{WDIOF_KEEPALIVEPING, "Keep alive ping reply"},
 };
 
 static void print_status(int flags)
 {
 	int wdiof = 0;
 
-	if (flags == WDIOS_UNKNOWN) {
+	if (flags == WDIOF_UNKNOWN) {
 		printf("Unknown status error from WDIOC_GETSTATUS\n");
 		return;
 	}
-- 
2.53.0