From: Lukasz Majewski Date: Tue, 03 Apr 2012 16:24:03 +0200 Subject: [U-Boot] [PATCH] mmc:fix Call mmc_init() when executing mmc_get_dev() Message-ID: <1333463043-11495-1-git-send-email-l.majewski@samsung.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 --- Test HW: - GONI S5PC110 - Universal C210 (Exynos4) --- drivers/mmc/mmc.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 618960e..1fa90e7 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1305,8 +1305,12 @@ int mmc_register(struct mmc *mmc) block_dev_desc_t *mmc_get_dev(int dev) { struct mmc *mmc = find_mmc_device(dev); + if (mmc) { + mmc_init(mmc); + return &mmc->block_dev; + } - return mmc ? &mmc->block_dev : NULL; + return NULL; } #endif -- 1.7.2.3