Skip to contentSkip to conversation

habanalabs: correctly cast variable to __le32

PATCH In review Oded Gabbay 2 participants 2 messages Sep 3, 2019 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 habanalabs: correctly cast variable to __le32

When using the macro le32_to_cpu(x), we need to correctly convert x to be __le32 in case it is defined as u32 variable.

---
 drivers/misc/habanalabs/habanalabs.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/misc/habanalabs/habanalabs.h +2 -2
index c39e07d665c4..75862be53c60 100644
@@ -1107,13 +1107,13 @@ void hl_wreg(struct hl_device *hdev, u32 reg, u32 val);
 		mb(); \
 		(val) = *((u32 *) (uintptr_t) (addr)); \
 		if (mem_written_by_device) \
-			(val) = le32_to_cpu(val); \
+			(val) = le32_to_cpu(*(__le32 *) &(val)); \
 		if (cond) \
 			break; \
 		if (timeout_us && ktime_compare(ktime_get(), __timeout) > 0) { \
 			(val) = *((u32 *) (uintptr_t) (addr)); \
 			if (mem_written_by_device) \
-				(val) = le32_to_cpu(val); \
+				(val) = le32_to_cpu(*(__le32 *) &(val)); \
 			break; \
 		} \
 		if (sleep_us) \
Signature · 1 line
2.17.1