From 40242bc394030871e6de13883fe1ace5c0b8e15b Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Majewski?= Date: Thu, 19 Apr 2012 02:39:18 +0000 Subject: [PATCH] mmc:fix Call mmc_init() when executing mmc_get_dev() 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 Signed-off-by: Kyungmin Park Cc: Andy Fleming Signed-off-by: Andy Fleming --- drivers/mmc/mmc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 9f746a3040..98e5af3ec9 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1306,8 +1306,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 -- 2.39.5