diff mbox

[U-Boot,2/3] cmd_mmc: Use init_mmc_device() from do_mmc_rescan()

Message ID 1400873087-20921-2-git-send-email-swarren@wwwdotorg.org
State Accepted
Delegated to: Pantelis Antoniou
Headers show

Commit Message

Stephen Warren May 23, 2014, 7:24 p.m. UTC
From: Stephen Warren <swarren@nvidia.com>

The body of init_mmc_device() is now identical to that of do_mmc_rescan()
except for the error codes returned. Modify do_mmc_rescan() to simply
call init_mmc_device() and convert the error codes, to avoid code
duplication.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 common/cmd_mmc.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

Comments

Pantelis Antoniou June 12, 2014, 11:29 a.m. UTC | #1
Hi Stephen,

On May 23, 2014, at 10:24 PM, Stephen Warren wrote:

> From: Stephen Warren <swarren@nvidia.com>
> 
> The body of init_mmc_device() is now identical to that of do_mmc_rescan()
> except for the error codes returned. Modify do_mmc_rescan() to simply
> call init_mmc_device() and convert the error codes, to avoid code
> duplication.
> 
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---
> common/cmd_mmc.c | 10 ++--------
> 1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
> index 6741ebee3bca..6c8db2e78c4f 100644
> --- a/common/cmd_mmc.c
> +++ b/common/cmd_mmc.c
> @@ -371,16 +371,10 @@ static int do_mmc_rescan(cmd_tbl_t *cmdtp, int flag,
> {
> 	struct mmc *mmc;
> 
> -	mmc = find_mmc_device(curr_device);
> -	if (!mmc) {
> -		printf("no mmc device at slot %x\n", curr_device);
> +	mmc = init_mmc_device(curr_device, true);
> +	if (!mmc)
> 		return CMD_RET_FAILURE;
> -	}
> -
> -	mmc->has_init = 0;
> 
> -	if (mmc_init(mmc))
> -		return CMD_RET_FAILURE;
> 	return CMD_RET_SUCCESS;
> }
> static int do_mmc_part(cmd_tbl_t *cmdtp, int flag,
> -- 
> 1.8.1.5
> 

Looks good.

Thanks, applied.

-- Pantelis

Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com>
diff mbox

Patch

diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index 6741ebee3bca..6c8db2e78c4f 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -371,16 +371,10 @@  static int do_mmc_rescan(cmd_tbl_t *cmdtp, int flag,
 {
 	struct mmc *mmc;
 
-	mmc = find_mmc_device(curr_device);
-	if (!mmc) {
-		printf("no mmc device at slot %x\n", curr_device);
+	mmc = init_mmc_device(curr_device, true);
+	if (!mmc)
 		return CMD_RET_FAILURE;
-	}
-
-	mmc->has_init = 0;
 
-	if (mmc_init(mmc))
-		return CMD_RET_FAILURE;
 	return CMD_RET_SUCCESS;
 }
 static int do_mmc_part(cmd_tbl_t *cmdtp, int flag,