summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Goodbody <[email protected]>2025-08-18 10:24:36 +0100
committerMichal Simek <[email protected]>2025-08-25 16:20:48 +0200
commit88e3524393fa88dbf675119aa89885bf144592ec (patch)
treec83761e86436a7197bbc8077f94bef834bebaa10
parent0109a7de96c64f5d4096652c36d7b6023b0f1737 (diff)
net: axi_emac: Fix timeout test
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michal Simek <[email protected]>
-rw-r--r--drivers/net/xilinx_axi_emac.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/net/xilinx_axi_emac.c b/drivers/net/xilinx_axi_emac.c
index c8038ddef1b..22e119370c8 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);
@@ -571,11 +571,11 @@ static void axi_dma_init(struct axidma_priv *priv)
if (!((readl(&priv->dmatx->control) |
readl(&priv->dmarx->control))
& XAXIDMA_CR_RESET_MASK)) {
- break;
+ return;
}
}
- if (!timeout)
- printf("%s: Timeout\n", __func__);
+
+ printf("%s: Timeout\n", __func__);
}
static int axiemac_start(struct udevice *dev)