blob: ec5f9426760242401c9d23f11556d49aeb69fb28 [file] [log] [blame]
Heiko Schochereda0ba32013-11-04 14:04:59 +01001/*
2 * (C) Copyright 2013
3 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#include <common.h>
Simon Glass01510092017-08-03 12:22:08 -06009#include <environment.h>
Heiko Schochereda0ba32013-11-04 14:04:59 +010010
11void bootcount_store(ulong a)
12{
13 int upgrade_available = getenv_ulong("upgrade_available", 10, 0);
14
15 if (upgrade_available) {
Simon Glass018f5302017-08-03 12:22:10 -060016 env_set_ulong("bootcount", a);
Simon Glass01510092017-08-03 12:22:08 -060017 env_save();
Heiko Schochereda0ba32013-11-04 14:04:59 +010018 }
19}
20
21ulong bootcount_load(void)
22{
23 int upgrade_available = getenv_ulong("upgrade_available", 10, 0);
24 ulong val = 0;
25
26 if (upgrade_available)
27 val = getenv_ulong("bootcount", 10, 0);
28
29 return val;
30}