Skip to contentSkip to conversation

mmc:fix Call mmc_init() when executing mmc_get_dev()

PATCH New Lukasz Majewski 2 participants 3 messages Apr 3, 2012 – Apr 18, 2012 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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

---
Test HW:
- GONI S5PC110
- Universal C210 (Exynos4)

---
 drivers/mmc/mmc.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
drivers/mmc/mmc.c +5 -1
index 618960e..1fa90e7 100644
@@ -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
 
Signature · 1 line
1.7.2.3
#1 lore raw

PATCH 1/1 mmc:fix Call mmc_init() when executing mmc_get_dev()

Hi Lukasz,

Quoted 41 lines · Lukasz Majewski

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

---
Test HW:
- GONI S5PC110
- Universal C210 (Exynos4)
---
?drivers/mmc/mmc.c | ? ?6 +++++-
?1 files changed, 5 insertions(+), 1 deletions(-)

drivers/mmc/mmc.c +5 -1
index 618960e..1fa90e7 100644
@@ -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;
 ?}
Quoted 2 lines

?#endif

I think

	if (!mmc)
		return NULL;

	mmc_init(mmc);
	return &mmc->block_dev;

is better.
How you think?

Thanks.
Minkyu Kang.

Signature · 2 lines
from. prom.
www.promsoft.net
#2 lore raw

PATCH 1/1 mmc:fix Call mmc_init() when executing mmc_get_dev()

Hi, Minkyu

Quoted 49 lines

Hi Lukasz,

Quoted 41 lines · Lukasz Majewski

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

---
Test HW:
- GONI S5PC110
- Universal C210 (Exynos4)
---
?drivers/mmc/mmc.c | ? ?6 +++++-
?1 files changed, 5 insertions(+), 1 deletions(-)

drivers/mmc/mmc.c +5 -1
index 618960e..1fa90e7 100644
@@ -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;
 ?}
Quoted 2 lines

?#endif

I think

Quoted 8 lines
	if (!mmc)
		return NULL;

	mmc_init(mmc);
	return &mmc->block_dev;

is better.
How you think?

Yes, it seems also more readable for me.
But anyway Andy shall express his opinion.

Signature · 6 lines
Best regards,

Lukasz Majewski

Samsung Poland R&D Center
Platform Group