From fff9c815291d5f4132976ac337337ea5813663e6 Mon Sep 17 00:00:00 2001 From: Roel Kluin Date: Wed, 26 Aug 2009 14:48:35 +0200 Subject: [PATCH] MIPS: Octeon: False positive timeout If we reach the test just below the loop with a `timeout' value of 0, this does not mean that the timeout caused the loop to end, but rather the `smi_rd.s.pending', in the last iteration. If timeout caused the loop to end, then `timeout' is -1, not 0. Since this can occur only in the last iteration, it is not very likely to be a problem. By changing the post- to prefix decrement we ensure that a timeout of 0 does mean it timed out. Signed-off-by: Roel Kluin Acked-by: David Daney Signed-off-by: Ralf Baechle --- drivers/staging/octeon/cvmx-mdio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/octeon/cvmx-mdio.h b/drivers/staging/octeon/cvmx-mdio.h index c987a75a20cf..f45dc49512f2 100644 --- a/drivers/staging/octeon/cvmx-mdio.h +++ b/drivers/staging/octeon/cvmx-mdio.h @@ -421,7 +421,7 @@ static inline int cvmx_mdio_45_read(int bus_id, int phy_id, int device, do { cvmx_wait(1000); smi_rd.u64 = cvmx_read_csr(CVMX_SMIX_RD_DAT(bus_id)); - } while (smi_rd.s.pending && timeout--); + } while (smi_rd.s.pending && --timeout); if (timeout <= 0) { cvmx_dprintf("cvmx_mdio_45_read: bus_id %d phy_id %2d " -- 2.30.2