From 77b5ad0ea3d132412f21daaa997b6249266ff71c Mon Sep 17 00:00:00 2001 From: Utkarsh Gupta Date: Thu, 15 Jun 2023 18:09:27 +0800 Subject: [PATCH] imx: fsl_sec: preprocessor casting issue with addresses involving math The sec_in32 preprocessor is defined as follows in include/fsl_sec.h file: When address "a" is calculated using math for ex: addition of base address and an offset, then casting is applied only to the first address which in this example is base address. caam_ccbvid_reg = sec_in32(CONFIG_SYS_FSL_SEC_ADDR + CAAM_CCBVID_OFFSET) resolves to: caam_ccbvid_reg = in_le32((ulong *)(ulong)CONFIG_SYS_FSL_SEC_ADDR + CAAM_CCBVID_OFFSET) instead it should resolve to: caam_ccbvid_reg = in_le32((ulong *)(ulong)(CONFIG_SYS_FSL_SEC_ADDR + CAAM_CCBVID_OFFSET)) Thus add parenthesis around the address "a" so that however the address is calculated, the casting is applied to the final calculated address. Reviewed-by: Horia Geanta Reviewed-by: Ye Li Signed-off-by: Utkarsh Gupta Signed-off-by: Peng Fan --- include/fsl_sec.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fsl_sec.h b/include/fsl_sec.h index d8861d1..9dad1d1 100644 --- a/include/fsl_sec.h +++ b/include/fsl_sec.h @@ -13,8 +13,8 @@ #include #ifdef CONFIG_SYS_FSL_SEC_LE -#define sec_in32(a) in_le32((ulong *)(ulong)a) -#define sec_out32(a, v) out_le32((ulong *)(ulong)a, v) +#define sec_in32(a) in_le32((ulong *)(ulong)(a)) +#define sec_out32(a, v) out_le32((ulong *)(ulong)(a), v) #define sec_in16(a) in_le16(a) #define sec_clrbits32 clrbits_le32 #define sec_setbits32 setbits_le32 -- 2.7.4