LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH] habanalabs: correctly cast variable to __le32
@ 2019-09-03  9:03 Oded Gabbay
  2019-09-03  9:25 ` Tomer Tayar
  0 siblings, 1 reply; 2+ messages in thread
From: Oded Gabbay @ 2019-09-03  9:03 UTC (permalink / raw
  To: linux-kernel, oshpigelman, ttayar; +Cc: gregkh

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.

Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
---
 drivers/misc/habanalabs/habanalabs.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/habanalabs/habanalabs.h b/drivers/misc/habanalabs/habanalabs.h
index c39e07d665c4..75862be53c60 100644
--- a/drivers/misc/habanalabs/habanalabs.h
+++ b/drivers/misc/habanalabs/habanalabs.h
@@ -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) \
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH] habanalabs: correctly cast variable to __le32
  2019-09-03  9:03 [PATCH] habanalabs: correctly cast variable to __le32 Oded Gabbay
@ 2019-09-03  9:25 ` Tomer Tayar
  0 siblings, 0 replies; 2+ messages in thread
From: Tomer Tayar @ 2019-09-03  9:25 UTC (permalink / raw
  To: Oded Gabbay, linux-kernel@vger.kernel.org, Omer Shpigelman
  Cc: gregkh@linuxfoundation.org

From: Oded Gabbay <oded.gabbay@gmail.com>
Sent: Tuesday, 3 September 2019 12:03
> 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.
> 
> Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>

Reviewed-by: Tomer Tayar <ttayar@habana.ai>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-09-03  9:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-03  9:03 [PATCH] habanalabs: correctly cast variable to __le32 Oded Gabbay
2019-09-03  9:25 ` Tomer Tayar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).