xref: /openbmc/linux/fs/ntfs/endian.h (revision 234489ac)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * endian.h - Defines for endianness handling in NTFS Linux kernel driver.
4  *	      Part of the Linux-NTFS project.
5  *
6  * Copyright (c) 2001-2004 Anton Altaparmakov
7  */
8 
9 #ifndef _LINUX_NTFS_ENDIAN_H
10 #define _LINUX_NTFS_ENDIAN_H
11 
12 #include <asm/byteorder.h>
13 #include "types.h"
14 
15 /*
16  * Signed endianness conversion functions.
17  */
18 
19 static inline s16 sle16_to_cpu(sle16 x)
20 {
21 	return le16_to_cpu((__force le16)x);
22 }
23 
24 static inline s32 sle32_to_cpu(sle32 x)
25 {
26 	return le32_to_cpu((__force le32)x);
27 }
28 
29 static inline s64 sle64_to_cpu(sle64 x)
30 {
31 	return le64_to_cpu((__force le64)x);
32 }
33 
34 static inline s16 sle16_to_cpup(sle16 *x)
35 {
36 	return le16_to_cpu(*(__force le16*)x);
37 }
38 
39 static inline s32 sle32_to_cpup(sle32 *x)
40 {
41 	return le32_to_cpu(*(__force le32*)x);
42 }
43 
44 static inline s64 sle64_to_cpup(sle64 *x)
45 {
46 	return le64_to_cpu(*(__force le64*)x);
47 }
48 
49 static inline sle16 cpu_to_sle16(s16 x)
50 {
51 	return (__force sle16)cpu_to_le16(x);
52 }
53 
54 static inline sle32 cpu_to_sle32(s32 x)
55 {
56 	return (__force sle32)cpu_to_le32(x);
57 }
58 
59 static inline sle64 cpu_to_sle64(s64 x)
60 {
61 	return (__force sle64)cpu_to_le64(x);
62 }
63 
64 static inline sle16 cpu_to_sle16p(s16 *x)
65 {
66 	return (__force sle16)cpu_to_le16(*x);
67 }
68 
69 static inline sle32 cpu_to_sle32p(s32 *x)
70 {
71 	return (__force sle32)cpu_to_le32(*x);
72 }
73 
74 static inline sle64 cpu_to_sle64p(s64 *x)
75 {
76 	return (__force sle64)cpu_to_le64(*x);
77 }
78 
79 #endif /* _LINUX_NTFS_ENDIAN_H */
80