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 | { |
| 13 | int upgrade_available = getenv_ulong("upgrade_available", 10, 0); |
| 14 | |
| 15 | if (upgrade_available) { |
| 16 | setenv_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 | { |
| 23 | int upgrade_available = getenv_ulong("upgrade_available", 10, 0); |
| 24 | ulong val = 0; |
| 25 | |
| 26 | if (upgrade_available) |
| 27 | val = getenv_ulong("bootcount", 10, 0); |
| 28 | |
| 29 | return val; |
| 30 | } |