[PATCH] net: axi_emac: Fix timeout test
Andrew Goodbody
andrew.goodbody at linaro.org
Wed Aug 6 13:10:52 CEST 2025
The timeout test in axi_dma_init is not correct due to the
post-decrement used on the timeout variable which will mean timeout is
not 0 if the timeout occurs. Make the timeout variable an int instead of
a u32 and then test for timeout being -1.
This issue was found by Smatch.
Signed-off-by: Andrew Goodbody <andrew.goodbody at linaro.org>
---
drivers/net/xilinx_axi_emac.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/xilinx_axi_emac.c b/drivers/net/xilinx_axi_emac.c
index c8038ddef1b..c46678c1f3b 100644
--- a/drivers/net/xilinx_axi_emac.c
+++ b/drivers/net/xilinx_axi_emac.c
@@ -558,7 +558,7 @@ static int axiemac_write_hwaddr(struct udevice *dev)
/* Reset DMA engine */
static void axi_dma_init(struct axidma_priv *priv)
{
- u32 timeout = 500;
+ int timeout = 500;
/* Reset the engine so the hardware starts from a known state */
writel(XAXIDMA_CR_RESET_MASK, &priv->dmatx->control);
@@ -574,7 +574,7 @@ static void axi_dma_init(struct axidma_priv *priv)
break;
}
}
- if (!timeout)
+ if (timeout == -1)
printf("%s: Timeout\n", __func__);
}
---
base-commit: 007610da2cca405ea7739fc120d90085be4b6ac2
change-id: 20250806-net_xilinx_axi-9ca9a791d611
Best regards,
--
Andrew Goodbody <andrew.goodbody at linaro.org>
More information about the U-Boot
mailing list