Comment 8 for bug 655461

Revision history for this message
Shawn Guo (shawnguo) wrote :

I tested the following patch on mx51evk and it works for me.

From 283f367cc2efa1a9e4a884c719f05c5eb3991b6b Mon Sep 17 00:00:00 2001
From: Shawn Guo <email address hidden>
Date: Fri, 8 Oct 2010 20:06:18 +0800
Subject: [PATCH] Make sure function mmc_init() is called before mmc read/write routine

Signed-off-by: Shawn Guo <email address hidden>
---
 drivers/mmc/mmc.c | 8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index cf4ea16..726daf3 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -90,6 +90,10 @@ mmc_bwrite(int dev_num, ulong start, lbaint_t blkcnt, const void*src)
        if (!mmc)
                return -1;

+ /* Ensure the call of mmc_init() */
+ if (!mmc->version)
+ mmc_init(mmc);
+
        blklen = mmc->write_bl_len;

        err = mmc_set_blocklen(mmc, mmc->write_bl_len);
@@ -219,6 +223,10 @@ static ulong mmc_bread(int dev_num, ulong start, lbaint_t blkcnt, void *dst)
        if (!mmc)
                return 0;

+ /* Ensure the call of mmc_init() */
+ if (!mmc->version)
+ mmc_init(mmc);
+
        /* We always do full block reads from the card */
        err = mmc_set_blocklen(mmc, mmc->read_bl_len);