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