[PATCH 4/4] ARM: imx: Correct bit count function

Joacim Zetterling joacim.zetterling at westermo.com
Fri Feb 25 06:47:51 PST 2022


Correct the imx_ddrc_count_bits which currently did a wrong
bit check (stopped after the first check).

Tested on a IMX8MN Evk with 2GB DDR4 and on a IMX8MN custom board
with 512MB LPDDR4, checked size and made memory test.

Signed-off-by: Joacim Zetterling <joacim.zetterling at westermo.com>
---
 arch/arm/mach-imx/esdctl.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-imx/esdctl.c b/arch/arm/mach-imx/esdctl.c
index 29333340318b..d3dbfff423da 100644
--- a/arch/arm/mach-imx/esdctl.c
+++ b/arch/arm/mach-imx/esdctl.c
@@ -355,8 +355,11 @@ imx_ddrc_count_bits(unsigned int bits, const u8 config[],
 		     unsigned int config_num)
 {
 	unsigned int i;
-	for (i = 0; i < config_num && config[i] == 0b1111; i++)
-		bits--;
+
+	for (i = 0; i < config_num; i++) {
+		if (config[i] == 0b1111)
+			bits--;
+	}
 
 	return bits;
 }
-- 
2.25.1




More information about the barebox mailing list