1 // SPDX-License-Identifier: GPL-2.0+
6 static int do_bootcount_print(struct cmd_tbl *cmdtp, int flag, int argc,
9 printf("%lu\n", bootcount_load());
10 return CMD_RET_SUCCESS;
13 static int do_bootcount_reset(struct cmd_tbl *cmdtp, int flag, int argc,
17 * note that we're explicitly not resetting the environment
18 * variable, so you still have the old bootcounter available
21 return CMD_RET_SUCCESS;
24 static struct cmd_tbl bootcount_sub[] = {
25 U_BOOT_CMD_MKENT(print, 1, 1, do_bootcount_print, "", ""),
26 U_BOOT_CMD_MKENT(reset, 1, 1, do_bootcount_reset, "", ""),
29 static int do_bootcount(struct cmd_tbl *cmdtp, int flag, int argc,
37 /* drop initial "bootcount" arg */
41 cp = find_cmd_tbl(argv[0], bootcount_sub, ARRAY_SIZE(bootcount_sub));
43 return cp->cmd(cmdtp, flag, argc, argv);
48 U_BOOT_LONGHELP(bootcount,
49 "print - print current bootcounter\n"
50 "reset - reset the bootcounter");
52 U_BOOT_CMD(bootcount, 2, 1, do_bootcount,