[U-Boot,4/7] mmc: Update the handling of returned erase block

Submitted by Haijun.Zhang on Nov. 5, 2013, 6:23 a.m.

Details

Message ID 1383632633-27262-4-git-send-email-Haijun.Zhang@freescale.com
State Superseded
Delegated to: Pantelis Antoniou
Headers show

Commit Message

Haijun.Zhang Nov. 5, 2013, 6:23 a.m.
If the block rang was not algined, We tried to algined the range,
then erase the block. So the block range erased should be less or
equal to the block range send. If error occured during erase procedure
part of them will be erased. And use should resend the block rang to
continue erase the reset of them.

Error number and zero number mean erase operation was failed.

Signed-off-by: Haijun Zhang <haijun.zhang@freescale.com>
---
 common/cmd_mmc.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Jaehoon Chung Nov. 8, 2013, 1:29 a.m.
Dear Haijun,

Check the below message, plz.

cmd_mmc.c: In function ‘do_mmcops’:
cmd_mmc.c:405:5: warning: comparisons like ‘X<=Y<=Z’ do not have their mathematical meaning [-Wparentheses]
cmd_mmc.c:406:5: warning: comparisons like ‘X<=Y<=Z’ do not have their mathematical meaning [-Wparentheses]
cmd_mmc.c:407:4: warning: comparisons like ‘X<=Y<=Z’ do not have their mathematical meaning [-Wparentheses]

Best Regards,
Jaehoon Chung

On 11/05/2013 03:23 PM, Haijun Zhang wrote:
> If the block rang was not algined, We tried to algined the range,
> then erase the block. So the block range erased should be less or
> equal to the block range send. If error occured during erase procedure
> part of them will be erased. And use should resend the block rang to
> continue erase the reset of them.
> 
> Error number and zero number mean erase operation was failed.
> 
> Signed-off-by: Haijun Zhang <haijun.zhang@freescale.com>
> ---
>  common/cmd_mmc.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
> index 67a94a7..15cecb7 100644
> --- a/common/cmd_mmc.c
> +++ b/common/cmd_mmc.c
> @@ -397,6 +397,13 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
>  			BUG();
>  		}
>  
> +		if (state == MMC_ERASE) {
> +			printf("%d blocks %s: %s\n",
> +				(cnt >= n > 0) ? n : 0, argv[1],
> +				(cnt >= n > 0) ? "OK" : "ERROR");
> +			return (cnt >= n > 0) ? 0 : 1;
> +		}
> +
>  		printf("%d blocks %s: %s\n",
>  				n, argv[1], (n == cnt) ? "OK" : "ERROR");
>  		return (n == cnt) ? 0 : 1;
>
Pantelis Antoniou Dec. 8, 2013, 11:21 a.m.
Hi Haijun,

On Nov 5, 2013, at 8:23 AM, Haijun Zhang wrote:

> If the block rang was not algined, We tried to algined the range,
> then erase the block. So the block range erased should be less or
> equal to the block range send. If error occured during erase procedure
> part of them will be erased. And use should resend the block rang to
> continue erase the reset of them.
> 
> Error number and zero number mean erase operation was failed.
> 
> Signed-off-by: Haijun Zhang <haijun.zhang@freescale.com>
> ---
> common/cmd_mmc.c | 7 +++++++
> 1 file changed, 7 insertions(+)
> 
> diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
> index 67a94a7..15cecb7 100644
> --- a/common/cmd_mmc.c
> +++ b/common/cmd_mmc.c
> @@ -397,6 +397,13 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> 			BUG();
> 		}
> 
> +		if (state == MMC_ERASE) {
> +			printf("%d blocks %s: %s\n",
> +				(cnt >= n > 0) ? n : 0, argv[1],
> +				(cnt >= n > 0) ? "OK" : "ERROR");
> +			return (cnt >= n > 0) ? 0 : 1;
> +		}
> +

I don't know what you think the test (cnt >= n > 0) does, but I bet it's not what you expect.

Are you trying to test: (cnt >= n & n > 0) ?

> 		printf("%d blocks %s: %s\n",
> 				n, argv[1], (n == cnt) ? "OK" : "ERROR");
> 		return (n == cnt) ? 0 : 1;
> -- 
> 1.8.4
> 
> 

Regards

-- Pantelis

Patch hide | download patch | download mbox

diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index 67a94a7..15cecb7 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -397,6 +397,13 @@  static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 			BUG();
 		}
 
+		if (state == MMC_ERASE) {
+			printf("%d blocks %s: %s\n",
+				(cnt >= n > 0) ? n : 0, argv[1],
+				(cnt >= n > 0) ? "OK" : "ERROR");
+			return (cnt >= n > 0) ? 0 : 1;
+		}
+
 		printf("%d blocks %s: %s\n",
 				n, argv[1], (n == cnt) ? "OK" : "ERROR");
 		return (n == cnt) ? 0 : 1;