1*b1b4e89aSStefan Roese #ifndef _LINUX_UNALIGNED_ACCESS_OK_H 2*b1b4e89aSStefan Roese #define _LINUX_UNALIGNED_ACCESS_OK_H 3*b1b4e89aSStefan Roese 4*b1b4e89aSStefan Roese #include <asm/byteorder.h> 5*b1b4e89aSStefan Roese 6*b1b4e89aSStefan Roese static inline u16 get_unaligned_le16(const void *p) 7*b1b4e89aSStefan Roese { 8*b1b4e89aSStefan Roese return le16_to_cpup((__le16 *)p); 9*b1b4e89aSStefan Roese } 10*b1b4e89aSStefan Roese 11*b1b4e89aSStefan Roese static inline u32 get_unaligned_le32(const void *p) 12*b1b4e89aSStefan Roese { 13*b1b4e89aSStefan Roese return le32_to_cpup((__le32 *)p); 14*b1b4e89aSStefan Roese } 15*b1b4e89aSStefan Roese 16*b1b4e89aSStefan Roese static inline u64 get_unaligned_le64(const void *p) 17*b1b4e89aSStefan Roese { 18*b1b4e89aSStefan Roese return le64_to_cpup((__le64 *)p); 19*b1b4e89aSStefan Roese } 20*b1b4e89aSStefan Roese 21*b1b4e89aSStefan Roese static inline u16 get_unaligned_be16(const void *p) 22*b1b4e89aSStefan Roese { 23*b1b4e89aSStefan Roese return be16_to_cpup((__be16 *)p); 24*b1b4e89aSStefan Roese } 25*b1b4e89aSStefan Roese 26*b1b4e89aSStefan Roese static inline u32 get_unaligned_be32(const void *p) 27*b1b4e89aSStefan Roese { 28*b1b4e89aSStefan Roese return be32_to_cpup((__be32 *)p); 29*b1b4e89aSStefan Roese } 30*b1b4e89aSStefan Roese 31*b1b4e89aSStefan Roese static inline u64 get_unaligned_be64(const void *p) 32*b1b4e89aSStefan Roese { 33*b1b4e89aSStefan Roese return be64_to_cpup((__be64 *)p); 34*b1b4e89aSStefan Roese } 35*b1b4e89aSStefan Roese 36*b1b4e89aSStefan Roese static inline void put_unaligned_le16(u16 val, void *p) 37*b1b4e89aSStefan Roese { 38*b1b4e89aSStefan Roese *((__le16 *)p) = cpu_to_le16(val); 39*b1b4e89aSStefan Roese } 40*b1b4e89aSStefan Roese 41*b1b4e89aSStefan Roese static inline void put_unaligned_le32(u32 val, void *p) 42*b1b4e89aSStefan Roese { 43*b1b4e89aSStefan Roese *((__le32 *)p) = cpu_to_le32(val); 44*b1b4e89aSStefan Roese } 45*b1b4e89aSStefan Roese 46*b1b4e89aSStefan Roese static inline void put_unaligned_le64(u64 val, void *p) 47*b1b4e89aSStefan Roese { 48*b1b4e89aSStefan Roese *((__le64 *)p) = cpu_to_le64(val); 49*b1b4e89aSStefan Roese } 50*b1b4e89aSStefan Roese 51*b1b4e89aSStefan Roese static inline void put_unaligned_be16(u16 val, void *p) 52*b1b4e89aSStefan Roese { 53*b1b4e89aSStefan Roese *((__be16 *)p) = cpu_to_be16(val); 54*b1b4e89aSStefan Roese } 55*b1b4e89aSStefan Roese 56*b1b4e89aSStefan Roese static inline void put_unaligned_be32(u32 val, void *p) 57*b1b4e89aSStefan Roese { 58*b1b4e89aSStefan Roese *((__be32 *)p) = cpu_to_be32(val); 59*b1b4e89aSStefan Roese } 60*b1b4e89aSStefan Roese 61*b1b4e89aSStefan Roese static inline void put_unaligned_be64(u64 val, void *p) 62*b1b4e89aSStefan Roese { 63*b1b4e89aSStefan Roese *((__be64 *)p) = cpu_to_be64(val); 64*b1b4e89aSStefan Roese } 65*b1b4e89aSStefan Roese 66*b1b4e89aSStefan Roese #endif /* _LINUX_UNALIGNED_ACCESS_OK_H */ 67