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> |
| 9 | |
| 10 | void bootcount_store(ulong a) |
| 11 | { |
| 12 | int upgrade_available = getenv_ulong("upgrade_available", 10, 0); |
| 13 | |
| 14 | if (upgrade_available) { |
| 15 | setenv_ulong("bootcount", a); |
| 16 | saveenv(); |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | ulong bootcount_load(void) |
| 21 | { |
| 22 | int upgrade_available = getenv_ulong("upgrade_available", 10, 0); |
| 23 | ulong val = 0; |
| 24 | |
| 25 | if (upgrade_available) |
| 26 | val = getenv_ulong("bootcount", 10, 0); |
| 27 | |
| 28 | return val; |
| 29 | } |