]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
net: fm: Correct test for timeout
authorAndrew Goodbody <andrew.goodbody@linaro.org>
Mon, 4 Aug 2025 16:03:59 +0000 (17:03 +0100)
committerPeng Fan <peng.fan@nxp.com>
Wed, 27 Aug 2025 07:39:58 +0000 (15:39 +0800)
In memac_wait_until_free and memac_wait_until_done the use of
post-decrement on the test in the while loop for a timeout means that
timeout will be equal to -1 on exit in that case. Adjust the test for
this expected value.

This issue was found by Smatch.

Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
drivers/net/fm/memac_phy.c

index 26425d94ae5573e48be8865447a775f09f1dcade..1ad3c053593173c3510e39efd5aaed72bb060f71 100644 (file)
@@ -46,7 +46,7 @@ static int memac_wait_until_free(struct memac_mdio_controller *regs)
        while ((memac_in_32(&regs->mdio_stat) & MDIO_STAT_BSY) && timeout--)
                ;
 
-       if (!timeout) {
+       if (timeout == -1) {
                printf("timeout waiting for MDIO bus to be free\n");
                return -ETIMEDOUT;
        }
@@ -64,7 +64,7 @@ static int memac_wait_until_done(struct memac_mdio_controller *regs)
        while ((memac_in_32(&regs->mdio_stat) & MDIO_STAT_BSY) && timeout--)
                ;
 
-       if (!timeout) {
+       if (timeout == -1) {
                printf("timeout waiting for MDIO operation to complete\n");
                return -ETIMEDOUT;
        }