diff mbox

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

Message ID 1386653960-4511-4-git-send-email-haijun.zhang@freescale.com
State Superseded
Delegated to: Pantelis Antoniou
Headers show

Commit Message

Haijun.Zhang Dec. 10, 2013, 5:39 a.m. UTC
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 sent. 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>
---
changes for V3:
	- no changes

 common/cmd_mmc.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Pantelis Antoniou Dec. 10, 2013, 8:28 a.m. UTC | #1
Hi Haijun,

On Dec 10, 2013, at 7:39 AM, Haijun Zhang wrote:

> If the block rang was not algined, We tried to algined the range,

range, aligned,

We try to align

> then erase the block. So the block range erased should be less or
> equal to the block range sent. If error occured during erase procedure
> part of them will be erased. And use should resend the block rang to
User? range

> continue erase the reset of them.
> 
the rest

> Error number and zero number mean erase operation was failed.
> 
Error return, zero return, has failed.

> Signed-off-by: Haijun Zhang <haijun.zhang@freescale.com>
> ---
> changes for V3:
> 	- no changes
> 
> common/cmd_mmc.c | 7 +++++++
> 1 file changed, 7 insertions(+)
> 
> diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
> index 67a94a7..c124df0 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",
> +				((n <= cnt) && (n > 0)) ? n : 0, argv[1],
> +				((n <= cnt) && (n > 0)) ? "OK" : "ERROR");
> +			return ((n <= cnt) && (n > 0)) ? 0 : 1;
> +		}
> +

Drop the inside parentheses
	(n <= cnt && n > 0)

Or use a variable like

int valid = n <= cnt && n > 0;

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

Patch

diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index 67a94a7..c124df0 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",
+				((n <= cnt) && (n > 0)) ? n : 0, argv[1],
+				((n <= cnt) && (n > 0)) ? "OK" : "ERROR");
+			return ((n <= cnt) && (n > 0)) ? 0 : 1;
+		}
+
 		printf("%d blocks %s: %s\n",
 				n, argv[1], (n == cnt) ? "OK" : "ERROR");
 		return (n == cnt) ? 0 : 1;