Heiko Schocher | 040c5c3 | 2013-11-04 14:04:59 +0100 | [diff] [blame] | 1 | /* |
| 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 Glass | d49b889 | 2017-08-03 12:22:08 -0600 | [diff] [blame] | 9 | #include <environment.h> |
Heiko Schocher | 040c5c3 | 2013-11-04 14:04:59 +0100 | [diff] [blame] | 10 | |
| 11 | void bootcount_store(ulong a) |
| 12 | { |
Simon Glass | 22c34c2 | 2017-08-03 12:22:13 -0600 | [diff] [blame] | 13 | int upgrade_available = env_get_ulong("upgrade_available", 10, 0); |
Heiko Schocher | 040c5c3 | 2013-11-04 14:04:59 +0100 | [diff] [blame] | 14 | |
| 15 | if (upgrade_available) { |
Simon Glass | 4d949a2 | 2017-08-03 12:22:10 -0600 | [diff] [blame] | 16 | env_set_ulong("bootcount", a); |
Simon Glass | d49b889 | 2017-08-03 12:22:08 -0600 | [diff] [blame] | 17 | env_save(); |
Heiko Schocher | 040c5c3 | 2013-11-04 14:04:59 +0100 | [diff] [blame] | 18 | } |
| 19 | } |
| 20 | |
| 21 | ulong bootcount_load(void) |
| 22 | { |
Simon Glass | 22c34c2 | 2017-08-03 12:22:13 -0600 | [diff] [blame] | 23 | int upgrade_available = env_get_ulong("upgrade_available", 10, 0); |
Heiko Schocher | 040c5c3 | 2013-11-04 14:04:59 +0100 | [diff] [blame] | 24 | ulong val = 0; |
| 25 | |
| 26 | if (upgrade_available) |
Simon Glass | 22c34c2 | 2017-08-03 12:22:13 -0600 | [diff] [blame] | 27 | val = env_get_ulong("bootcount", 10, 0); |
Heiko Schocher | 040c5c3 | 2013-11-04 14:04:59 +0100 | [diff] [blame] | 28 | |
| 29 | return val; |
| 30 | } |