bootcount: Add include guards into bootcount.h file
[oweals/u-boot.git] / include / bootcount.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * (C) Copyright 2012
4  * Stefan Roese, DENX Software Engineering, sr@denx.de.
5  */
6 #ifndef _BOOTCOUNT_H__
7 #define _BOOTCOUNT_H__
8
9 #include <common.h>
10 #include <asm/io.h>
11 #include <asm/byteorder.h>
12
13 #if !defined(CONFIG_SYS_BOOTCOUNT_LE) && !defined(CONFIG_SYS_BOOTCOUNT_BE)
14 # if __BYTE_ORDER == __LITTLE_ENDIAN
15 #  define CONFIG_SYS_BOOTCOUNT_LE
16 # else
17 #  define CONFIG_SYS_BOOTCOUNT_BE
18 # endif
19 #endif
20
21 #ifdef CONFIG_SYS_BOOTCOUNT_LE
22 static inline void raw_bootcount_store(volatile u32 *addr, u32 data)
23 {
24         out_le32(addr, data);
25 }
26
27 static inline u32 raw_bootcount_load(volatile u32 *addr)
28 {
29         return in_le32(addr);
30 }
31 #else
32 static inline void raw_bootcount_store(volatile u32 *addr, u32 data)
33 {
34         out_be32(addr, data);
35 }
36
37 static inline u32 raw_bootcount_load(volatile u32 *addr)
38 {
39         return in_be32(addr);
40 }
41 #endif
42 #endif /* _BOOTCOUNT_H__ */