Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Heiko Schocher | 040c5c3 | 2013-11-04 14:04:59 +0100 | [diff] [blame] | 2 | /* |
3 | * (C) Copyright 2013 | ||||
4 | * Heiko Schocher, DENX Software Engineering, hs@denx.de. | ||||
Heiko Schocher | 040c5c3 | 2013-11-04 14:04:59 +0100 | [diff] [blame] | 5 | */ |
6 | |||||
Simon Glass | 07dc93c | 2019-08-01 09:46:47 -0600 | [diff] [blame] | 7 | #include <env.h> |
Heiko Schocher | 040c5c3 | 2013-11-04 14:04:59 +0100 | [diff] [blame] | 8 | |
9 | void bootcount_store(ulong a) | ||||
10 | { | ||||
Simon Glass | 22c34c2 | 2017-08-03 12:22:13 -0600 | [diff] [blame] | 11 | int upgrade_available = env_get_ulong("upgrade_available", 10, 0); |
Heiko Schocher | 040c5c3 | 2013-11-04 14:04:59 +0100 | [diff] [blame] | 12 | |
13 | if (upgrade_available) { | ||||
Simon Glass | 4d949a2 | 2017-08-03 12:22:10 -0600 | [diff] [blame] | 14 | env_set_ulong("bootcount", a); |
Simon Glass | d49b889 | 2017-08-03 12:22:08 -0600 | [diff] [blame] | 15 | env_save(); |
Heiko Schocher | 040c5c3 | 2013-11-04 14:04:59 +0100 | [diff] [blame] | 16 | } |
17 | } | ||||
18 | |||||
19 | ulong bootcount_load(void) | ||||
20 | { | ||||
Simon Glass | 22c34c2 | 2017-08-03 12:22:13 -0600 | [diff] [blame] | 21 | int upgrade_available = env_get_ulong("upgrade_available", 10, 0); |
Heiko Schocher | 040c5c3 | 2013-11-04 14:04:59 +0100 | [diff] [blame] | 22 | ulong val = 0; |
23 | |||||
24 | if (upgrade_available) | ||||
Simon Glass | 22c34c2 | 2017-08-03 12:22:13 -0600 | [diff] [blame] | 25 | val = env_get_ulong("bootcount", 10, 0); |
Heiko Schocher | 040c5c3 | 2013-11-04 14:04:59 +0100 | [diff] [blame] | 26 | |
27 | return val; | ||||
28 | } |