spi-topcliff-pch: supports a spi mode setup and bit order setup by IO control
[zen-stable.git] / tools / include / tools / le_byteshift.h
blobc99d45a68bda8a0e7c1054dbf81606d4417eef22
1 #ifndef _TOOLS_LE_BYTESHIFT_H
2 #define _TOOLS_LE_BYTESHIFT_H
4 #include <linux/types.h>
6 static inline __u16 __get_unaligned_le16(const __u8 *p)
8 return p[0] | p[1] << 8;
11 static inline __u32 __get_unaligned_le32(const __u8 *p)
13 return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24;
16 static inline __u64 __get_unaligned_le64(const __u8 *p)
18 return (__u64)__get_unaligned_le32(p + 4) << 32 |
19 __get_unaligned_le32(p);
22 static inline void __put_unaligned_le16(__u16 val, __u8 *p)
24 *p++ = val;
25 *p++ = val >> 8;
28 static inline void __put_unaligned_le32(__u32 val, __u8 *p)
30 __put_unaligned_le16(val >> 16, p + 2);
31 __put_unaligned_le16(val, p);
34 static inline void __put_unaligned_le64(__u64 val, __u8 *p)
36 __put_unaligned_le32(val >> 32, p + 4);
37 __put_unaligned_le32(val, p);
40 static inline __u16 get_unaligned_le16(const void *p)
42 return __get_unaligned_le16((const __u8 *)p);
45 static inline __u32 get_unaligned_le32(const void *p)
47 return __get_unaligned_le32((const __u8 *)p);
50 static inline __u64 get_unaligned_le64(const void *p)
52 return __get_unaligned_le64((const __u8 *)p);
55 static inline void put_unaligned_le16(__u16 val, void *p)
57 __put_unaligned_le16(val, p);
60 static inline void put_unaligned_le32(__u32 val, void *p)
62 __put_unaligned_le32(val, p);
65 static inline void put_unaligned_le64(__u64 val, void *p)
67 __put_unaligned_le64(val, p);
70 #endif /* _TOOLS_LE_BYTESHIFT_H */