Patchwork [U-Boot,RESEND,2/2] mmc:fix Call mmc_init() when executing mmc_get_dev()

login
register
mail settings
Submitter Łukasz Majewski
Date April 19, 2012, 12:39 p.m.
Message ID <1334839158-23544-3-git-send-email-l.majewski@samsung.com>
Download mbox | patch
Permalink /patch/153744/
State Accepted
Commit 40242bc394030871e6de13883fe1ace5c0b8e15b
Delegated to: Andy Fleming
Headers show

Comments

Łukasz Majewski - April 19, 2012, 12:39 p.m.
This code adds call to mmc_init(), for partition related commands (e.g.
fatls, fatinfo etc.).

It is safe to call mmc_init() multiple times since mmc->has_init flag
prevents from multiple initialization.

The FAT related code calls get_dev high level method and then uses
elements from mmc->block_dev, which is uninitialized until the mmc_init
(and thereof mmc_startup) is called.

This problem appears on boards, which don't use mmc as the default
place for envs

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Andy Fleming <afleming@gmail.com>
---
 drivers/mmc/mmc.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

Patch

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 618960e..84eb4e0 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1305,8 +1305,11 @@  int mmc_register(struct mmc *mmc)
 block_dev_desc_t *mmc_get_dev(int dev)
 {
 	struct mmc *mmc = find_mmc_device(dev);
+	if (!mmc)
+		return NULL;
 
-	return mmc ? &mmc->block_dev : NULL;
+	mmc_init(mmc);
+	return &mmc->block_dev;
 }
 #endif