• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. */
3 
4 #include <linux/kernel.h>
5 #include "gdm_endian.h"
6 
gdm_cpu_to_dev16(u8 dev_ed,u16 x)7 __dev16 gdm_cpu_to_dev16(u8 dev_ed, u16 x)
8 {
9 	if (dev_ed == ENDIANNESS_LITTLE)
10 		return (__force __dev16)cpu_to_le16(x);
11 	else
12 		return (__force __dev16)cpu_to_be16(x);
13 }
14 
gdm_dev16_to_cpu(u8 dev_ed,__dev16 x)15 u16 gdm_dev16_to_cpu(u8 dev_ed, __dev16 x)
16 {
17 	if (dev_ed == ENDIANNESS_LITTLE)
18 		return le16_to_cpu((__force __le16)x);
19 	else
20 		return be16_to_cpu((__force __be16)x);
21 }
22 
gdm_cpu_to_dev32(u8 dev_ed,u32 x)23 __dev32 gdm_cpu_to_dev32(u8 dev_ed, u32 x)
24 {
25 	if (dev_ed == ENDIANNESS_LITTLE)
26 		return (__force __dev32)cpu_to_le32(x);
27 	else
28 		return (__force __dev32)cpu_to_be32(x);
29 }
30 
gdm_dev32_to_cpu(u8 dev_ed,__dev32 x)31 u32 gdm_dev32_to_cpu(u8 dev_ed, __dev32 x)
32 {
33 	if (dev_ed == ENDIANNESS_LITTLE)
34 		return le32_to_cpu((__force __le32)x);
35 	else
36 		return be32_to_cpu((__force __be32)x);
37 }
38