From: Moritz Fischer Date: Mon, 16 Jan 2017 17:50:45 +0000 (-0800) Subject: i2c: i2c-cdns: Reorder timeout loop for interrupt waiting X-Git-Tag: v2017.03-rc1~94^2~2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0ec0c5864365f3f222e1652aca98cfbd86bae890;p=u-boot i2c: i2c-cdns: Reorder timeout loop for interrupt waiting Reorder the timeout loop such that we first check if the condition is already true, and then call udelay() so if the condition is already true, break early. Reviewed-by: Michal Simek Signed-off-by: Moritz Fischer Cc: Heiko Schocher Cc: Michal Simek Cc: u-boot@lists.denx.de --- diff --git a/drivers/i2c/i2c-cdns.c b/drivers/i2c/i2c-cdns.c index c1d64273c5..1c9fda8f66 100644 --- a/drivers/i2c/i2c-cdns.c +++ b/drivers/i2c/i2c-cdns.c @@ -130,10 +130,10 @@ static u32 cdns_i2c_wait(struct cdns_i2c_regs *cdns_i2c, u32 mask) int timeout, int_status; for (timeout = 0; timeout < 100; timeout++) { - udelay(100); int_status = readl(&cdns_i2c->interrupt_status); if (int_status & mask) break; + udelay(100); } /* Clear interrupt status flags */