Skip to content

Commit

Permalink
selftests: watchdog: Add command line option to show watchdog_info
Browse files Browse the repository at this point in the history
With the new ioctl(WDIOC_GETSUPPORT) call in place, add a command
line option to show the watchdog_info.

Suggested-by: Eugeniu Rosca <erosca@de.adit-jv.com>
Signed-off-by: George G. Davis <george_davis@mentor.com>
Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
  • Loading branch information
George G. Davis authored and Shuah Khan committed Oct 2, 2019
1 parent 8f9577e commit ce3a677
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tools/testing/selftests/watchdog/watchdog-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

int fd;
const char v = 'V';
static const char sopts[] = "bdehp:t:Tn:NLf:";
static const char sopts[] = "bdehp:t:Tn:NLf:i";
static const struct option lopts[] = {
{"bootstatus", no_argument, NULL, 'b'},
{"disable", no_argument, NULL, 'd'},
Expand All @@ -32,6 +32,7 @@ static const struct option lopts[] = {
{"getpretimeout", no_argument, NULL, 'N'},
{"gettimeleft", no_argument, NULL, 'L'},
{"file", required_argument, NULL, 'f'},
{"info", no_argument, NULL, 'i'},
{NULL, no_argument, NULL, 0x0}
};

Expand Down Expand Up @@ -72,6 +73,7 @@ static void usage(char *progname)
printf("Usage: %s [options]\n", progname);
printf(" -f, --file\t\tOpen watchdog device file\n");
printf("\t\t\tDefault is /dev/watchdog\n");
printf(" -i, --info\t\tShow watchdog_info\n");
printf(" -b, --bootstatus\tGet last boot status (Watchdog/POR)\n");
printf(" -d, --disable\t\tTurn off the watchdog timer\n");
printf(" -e, --enable\t\tTurn on the watchdog timer\n");
Expand Down Expand Up @@ -216,6 +218,18 @@ int main(int argc, char *argv[])
case 'f':
/* Handled above */
break;
case 'i':
/*
* watchdog_info was obtained as part of file open
* validation. So we just show it here.
*/
oneshot = 1;
printf("watchdog_info:\n");
printf(" identity:\t\t%s\n", info.identity);
printf(" firmware_version:\t%u\n",
info.firmware_version);
printf(" options:\t\t%08x\n", info.options);
break;

default:
usage(argv[0]);
Expand Down

0 comments on commit ce3a677

Please sign in to comment.