diff mbox series

[3/4] xilinx: zynqmp: Do not check 0 as invalid return from snprintf

Message ID ed108efda514628c0de91859640461b0fd83ca03.1603276156.git.michal.simek@xilinx.com
State Accepted
Commit 07499daf507cecbe85e959d54aa1b6972905d8c7
Delegated to: Michal Simek
Headers show
Series xilinx: zynqmp: Fixes for silicon ID detection | expand

Commit Message

Michal Simek Oct. 21, 2020, 10:29 a.m. UTC
U-Boot SPL on ZynqMP is using CONFIG_SPL_USE_TINY_PRINTF which doesn't
return any return value and all the time returns 0. That's why
even correct snprintf was returning in SPL chip ID as "unknown".
Change checking condition and allow snprintf to return 0 which is according
manual patch successful return.
"If an output error is encountered, a negative value is returned."

Fixes: 43a138956f7e ("arm64: zynqmp: Get rid of simple_itoa and replace it by snprintf")
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 board/xilinx/zynqmp/zynqmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
index 7ba2c789751e..c4f24982843e 100644
--- a/board/xilinx/zynqmp/zynqmp.c
+++ b/board/xilinx/zynqmp/zynqmp.c
@@ -223,7 +223,7 @@  static char *zynqmp_get_silicon_idcode_name(void)
 	/* Add device prefix to the name */
 	ret = snprintf(name, ZYNQMP_VERSION_SIZE, "zu%d",
 		       zynqmp_devices[i].device);
-	if (ret <= 0)
+	if (ret < 0)
 		return "unknown";
 
 	if (zynqmp_devices[i].variants & ZYNQMP_VARIANT_EV) {