Patchwork [U-Boot,1/2] mmc: mmc_getcd/getwp: use sensible defaults

login
register
mail settings
Submitter Tom Rini
Date March 26, 2013, 2:51 p.m.
Message ID <20130326145115.GB5711@bill-the-cat>
Download mbox | patch
Permalink /patch/231250/
State Accepted
Delegated to: Tom Rini
Headers show

Comments

Tom Rini - March 26, 2013, 2:51 p.m.
On Thu, Mar 21, 2013 at 03:00:03PM +0100, Peter Korsgaard wrote:

> Let mmc_getcd() return true and mmc_getwp() false if mmc driver doesn't
> provide handlers for them.
> 
> Signed-off-by: Peter Korsgaard <peter.korsgaard@barco.com>
> ---
>  drivers/mmc/mmc.c |   14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index 7b5fdd9..54d23eb 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -51,8 +51,11 @@ int mmc_getwp(struct mmc *mmc)
>  
>  	wp = board_mmc_getwp(mmc);
>  
> -	if ((wp < 0) && mmc->getwp)
> -		wp = mmc->getwp(mmc);
> +	if (wp < 0)
> +		if (mmc->getwp)
> +			wp = mmc->getwp(mmc);
> +		else
> +			wp = 0;
>  
>  	return wp;
>  }
> @@ -692,8 +695,11 @@ int mmc_getcd(struct mmc *mmc)
>  
>  	cd = board_mmc_getcd(mmc);
>  
> -	if ((cd < 0) && mmc->getcd)
> -		cd = mmc->getcd(mmc);
> +	if (cd < 0)
> +		if (mmc->getcd)
> +			cd = mmc->getcd(mmc);
> +		else
> +			cd = 1;
>  
>  	return cd;
>  }

With the following to fix a build warning:


Applied to u-boot-ti/master, thanks!

Patch

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 54d23eb..d732581 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -51,11 +51,12 @@  int mmc_getwp(struct mmc *mmc)
 
 	wp = board_mmc_getwp(mmc);
 
-	if (wp < 0)
+	if (wp < 0) {
 		if (mmc->getwp)
 			wp = mmc->getwp(mmc);
 		else
 			wp = 0;
+	}
 
 	return wp;
 }
@@ -695,11 +696,12 @@  int mmc_getcd(struct mmc *mmc)
 
 	cd = board_mmc_getcd(mmc);
 
-	if (cd < 0)
+	if (cd < 0) {
 		if (mmc->getcd)
 			cd = mmc->getcd(mmc);
 		else
 			cd = 1;
+	}
 
 	return cd;
 }