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@linaro.org>
Link: https://lore.kernel.org/r/20250806-net_xilinx_axi-v2-1-6311cf59451d@linaro.org
Signed-off-by: Michal Simek <michal.simek@amd.com>
/* 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);
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)