diff mbox

[U-Boot,v2,12/12] ums: always initialize mmc before ums_disk_init()

Message ID 1391533364-17663-13-git-send-email-m.zalega@samsung.com
State Superseded
Delegated to: Marek Vasut
Headers show

Commit Message

Mateusz Zalega Feb. 4, 2014, 5:02 p.m. UTC
In some cases MMC was still uninitialized while media capacity check,
leading to broken ums command.

Tested on Samsung Goni.

Signed-off-by: Mateusz Zalega <m.zalega@samsung.com>
Cc: Minkyu Kang <mk7.kang@samsung.com>
---
Changes since v1:
- patch conforms to kernel coding style
- moved mmc_init() check to ums_init()
---
 board/samsung/common/ums.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Comments

Marek Vasut Feb. 22, 2014, 5:12 a.m. UTC | #1
On Tuesday, February 04, 2014 at 06:02:44 PM, Mateusz Zalega wrote:
> In some cases MMC was still uninitialized while media capacity check,
> leading to broken ums command.

Sorry, this really doesn't explain what was the bug, what caused the bug and why 
this actually solves the problem.

Best regards,
Marek Vasut
diff mbox

Patch

diff --git a/board/samsung/common/ums.c b/board/samsung/common/ums.c
index dc155ad..1375138 100644
--- a/board/samsung/common/ums.c
+++ b/board/samsung/common/ums.c
@@ -35,10 +35,10 @@  static struct ums ums_dev = {
 	.name = "UMS disk",
 };
 
-static struct ums *ums_disk_init(struct mmc *mmc)
+static struct ums *ums_disk_init(const struct mmc *mmc)
 {
-	uint64_t mmc_end_sector = mmc->capacity / SECTOR_SIZE;
-	uint64_t ums_end_sector = UMS_NUM_SECTORS + UMS_START_SECTOR;
+	const uint64_t mmc_end_sector = mmc->capacity / SECTOR_SIZE;
+	const uint64_t ums_end_sector = UMS_NUM_SECTORS + UMS_START_SECTOR;
 
 	if (!mmc_end_sector) {
 		error("MMC capacity is not valid");
@@ -66,11 +66,9 @@  static struct ums *ums_disk_init(struct mmc *mmc)
 
 struct ums *ums_init(unsigned int dev_num)
 {
-	struct mmc *mmc = NULL;
+	struct mmc *mmc = find_mmc_device(dev_num);
 
-	mmc = find_mmc_device(dev_num);
-	if (!mmc)
+	if (!mmc || mmc_init(mmc))
 		return NULL;
-
 	return ums_disk_init(mmc);
 }