[U-Boot] [PATCH RESEND v2 2/4] i2c: i2c-cdns: Reorder timeout loop for interrupt waiting

Moritz Fischer moritz.fischer at ettus.com
Mon Jan 16 18:50:45 CET 2017


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 <michal.simek at xilinx.com>
Signed-off-by: Moritz Fischer <moritz.fischer at ettus.com>
Cc: Heiko Schocher <hs at denx.de>
Cc: Michal Simek <michal.simek at xilinx.com>
Cc: u-boot at lists.denx.de
---
Changes from v1:
- None

---
 drivers/i2c/i2c-cdns.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/i2c-cdns.c b/drivers/i2c/i2c-cdns.c
index c1d6427..1c9fda8 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 */
-- 
2.7.4



More information about the U-Boot mailing list