[PATCH] staging: gdm724x: add forced casts in endian converters to fix sparse warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The modified functions do explicit endian checking and conversion. The
added forced casts fix these sparse warnings:

CHECK   drivers/staging/gdm724x/gdm_endian.c
drivers/staging/gdm724x/gdm_endian.c:28:24: warning: incorrect type in return expression (different base types)
drivers/staging/gdm724x/gdm_endian.c:28:24:    expected unsigned short
drivers/staging/gdm724x/gdm_endian.c:28:24:    got restricted __le16 [usertype] <noident>
drivers/staging/gdm724x/gdm_endian.c:30:24: warning: incorrect type in return expression (different base types)
drivers/staging/gdm724x/gdm_endian.c:30:24:    expected unsigned short
drivers/staging/gdm724x/gdm_endian.c:30:24:    got restricted __be16 [usertype] <noident>
drivers/staging/gdm724x/gdm_endian.c:36:24: warning: cast to restricted __le16
drivers/staging/gdm724x/gdm_endian.c:38:24: warning: cast to restricted __be16
drivers/staging/gdm724x/gdm_endian.c:44:24: warning: incorrect type in return expression (different base types)
drivers/staging/gdm724x/gdm_endian.c:44:24:    expected unsigned int
drivers/staging/gdm724x/gdm_endian.c:44:24:    got restricted __le32 [usertype] <noident>
drivers/staging/gdm724x/gdm_endian.c:46:24: warning: incorrect type in return expression (different base types)
drivers/staging/gdm724x/gdm_endian.c:46:24:    expected unsigned int
drivers/staging/gdm724x/gdm_endian.c:46:24:    got restricted __be32 [usertype] <noident>
drivers/staging/gdm724x/gdm_endian.c:52:24: warning: cast to restricted __le32
drivers/staging/gdm724x/gdm_endian.c:54:24: warning: cast to restricted __be32

Signed-off-by: Eric S. Stone <esstone@xxxxxxxxx>
---
 drivers/staging/gdm724x/gdm_endian.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/gdm724x/gdm_endian.c b/drivers/staging/gdm724x/gdm_endian.c
index d7144e7..00ae7a8 100644
--- a/drivers/staging/gdm724x/gdm_endian.c
+++ b/drivers/staging/gdm724x/gdm_endian.c
@@ -25,31 +25,31 @@ void gdm_set_endian(struct gdm_endian *ed, u8 dev_endian)
 u16 gdm_cpu_to_dev16(struct gdm_endian *ed, u16 x)
 {
 	if (ed->dev_ed == ENDIANNESS_LITTLE)
-		return cpu_to_le16(x);
+		return (__force u16)cpu_to_le16(x);
 	else
-		return cpu_to_be16(x);
+		return (__force u16)cpu_to_be16(x);
 }
 
 u16 gdm_dev16_to_cpu(struct gdm_endian *ed, u16 x)
 {
 	if (ed->dev_ed == ENDIANNESS_LITTLE)
-		return le16_to_cpu(x);
+		return le16_to_cpu((__force __le16)x);
 	else
-		return be16_to_cpu(x);
+		return be16_to_cpu((__force __be16)x);
 }
 
 u32 gdm_cpu_to_dev32(struct gdm_endian *ed, u32 x)
 {
 	if (ed->dev_ed == ENDIANNESS_LITTLE)
-		return cpu_to_le32(x);
+		return (__force u32)cpu_to_le32(x);
 	else
-		return cpu_to_be32(x);
+		return (__force u32)cpu_to_be32(x);
 }
 
 u32 gdm_dev32_to_cpu(struct gdm_endian *ed, u32 x)
 {
 	if (ed->dev_ed == ENDIANNESS_LITTLE)
-		return le32_to_cpu(x);
+		return le32_to_cpu((__force __le32)x);
 	else
-		return be32_to_cpu(x);
+		return be32_to_cpu((__force __be32)x);
 }
-- 
2.9.3

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux