blob: 960cd71b9d562cccc35a8c82ada5455a1246862c [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Heiko Schocher040c5c32013-11-04 14:04:59 +01002/*
3 * (C) Copyright 2013
4 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
Heiko Schocher040c5c32013-11-04 14:04:59 +01005 */
6
Simon Glass07dc93c2019-08-01 09:46:47 -06007#include <env.h>
Heiko Schocher040c5c32013-11-04 14:04:59 +01008
9void bootcount_store(ulong a)
10{
Simon Glass22c34c22017-08-03 12:22:13 -060011 int upgrade_available = env_get_ulong("upgrade_available", 10, 0);
Heiko Schocher040c5c32013-11-04 14:04:59 +010012
13 if (upgrade_available) {
Simon Glass4d949a22017-08-03 12:22:10 -060014 env_set_ulong("bootcount", a);
Simon Glassd49b8892017-08-03 12:22:08 -060015 env_save();
Heiko Schocher040c5c32013-11-04 14:04:59 +010016 }
17}
18
19ulong bootcount_load(void)
20{
Simon Glass22c34c22017-08-03 12:22:13 -060021 int upgrade_available = env_get_ulong("upgrade_available", 10, 0);
Heiko Schocher040c5c32013-11-04 14:04:59 +010022 ulong val = 0;
23
24 if (upgrade_available)
Simon Glass22c34c22017-08-03 12:22:13 -060025 val = env_get_ulong("bootcount", 10, 0);
Heiko Schocher040c5c32013-11-04 14:04:59 +010026
27 return val;
28}