Patchwork [U-Boot,v2] mmc: fix wrong timeout check in mmc_send_status()

login
register
mail settings
Submitter Jongman Heo
Date June 4, 2012, 7:32 a.m.
Message ID <CAHFnbAmKmQomt6ZVm=LEuceoKgR29esvjwdAtGmpNB-kKv7mVA@mail.gmail.com>
Download mbox | patch
Permalink /patch/162666/
State Accepted
Commit 5b0c942f8919ed962699a44e0abb4f8a599c52c1
Delegated to: Andy Fleming
Headers show

Comments

Jongman Heo - June 4, 2012, 7:32 a.m.
(!timeout) condition check in mmc_send_status() can never be met,
because do-while loop ends up with negative timeout value, -1.

Fix the check to handle TIMEOUT case correctly.

Signed-off-by: Jongman Heo <jongman.heo@gmail.com>
---
 drivers/mmc/mmc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Patch

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index aebe578..d3cca6c 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -238,7 +238,7 @@  int mmc_send_status(struct mmc *mmc, int timeout)
 	status = (cmd.response[0] & MMC_STATUS_CURR_STATE) >> 9;
 	printf("CURR STATE:%d\n", status);
 #endif
-	if (!timeout) {
+	if (timeout <= 0) {
 		printf("Timeout waiting card ready\n");
 		return TIMEOUT;
 	}