blob: c3618d3a596b624fb382fda0e134b0d663720468 [file] [log] [blame]
Heiko Schocher040c5c32013-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 Glassd49b8892017-08-03 12:22:08 -06009#include <environment.h>
Heiko Schocher040c5c32013-11-04 14:04:59 +010010
11void bootcount_store(ulong a)
12{
Simon Glass22c34c22017-08-03 12:22:13 -060013 int upgrade_available = env_get_ulong("upgrade_available", 10, 0);
Heiko Schocher040c5c32013-11-04 14:04:59 +010014
15 if (upgrade_available) {
Simon Glass4d949a22017-08-03 12:22:10 -060016 env_set_ulong("bootcount", a);
Simon Glassd49b8892017-08-03 12:22:08 -060017 env_save();
Heiko Schocher040c5c32013-11-04 14:04:59 +010018 }
19}
20
21ulong bootcount_load(void)
22{
Simon Glass22c34c22017-08-03 12:22:13 -060023 int upgrade_available = env_get_ulong("upgrade_available", 10, 0);
Heiko Schocher040c5c32013-11-04 14:04:59 +010024 ulong val = 0;
25
26 if (upgrade_available)
Simon Glass22c34c22017-08-03 12:22:13 -060027 val = env_get_ulong("bootcount", 10, 0);
Heiko Schocher040c5c32013-11-04 14:04:59 +010028
29 return val;
30}