[U-Boot] [PATCH] cmd/nand.c: Remove unnecessarily repeated step
Benoît Thébaudeau
benoit.thebaudeau.dev at gmail.com
Thu Oct 13 23:15:27 CEST 2016
Dear Ahmed Samir Khalil,
On Mon, Oct 10, 2016 at 6:44 AM, Ahmed Samir Khalil
<engkhalil86 at gmail.com> wrote:
> Getting the current NAND device is already done once as part
> of nand command. Therefore, repeating this step as part of
> the sub-commands is unnecessary.
>
> Signed-off-by: Ahmed Samir Khalil <engkhalil86 at gmail.com>
> ---
> cmd/nand.c | 6 ------
> 1 file changed, 6 deletions(-)
>
> diff --git a/cmd/nand.c b/cmd/nand.c
> index ec7f1df..71ffe85 100644
> --- a/cmd/nand.c
> +++ b/cmd/nand.c
> @@ -528,8 +528,6 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> if (set_dev(dev))
> return 1;
>
> - mtd = nand_info[dev];
> -
> memset(&opts, 0, sizeof(opts));
> opts.offset = off;
> opts.length = size;
> @@ -597,8 +595,6 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> if (set_dev(dev))
> return 1;
>
> - mtd = nand_info[dev];
> -
> if (argc > 4 && !str2long(argv[4], &pagecount)) {
> printf("'%s' is not a number\n", argv[4]);
> return 1;
> @@ -626,8 +622,6 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> rwsize = size;
> }
>
> - mtd = nand_info[dev];
> -
> if (!s || !strcmp(s, ".jffs2") ||
> !strcmp(s, ".e") || !strcmp(s, ".i")) {
> if (read)
Quickly looking at the code, these assignments of mtd directly follow
calls to mtd_arg_off_size(), which may alter dev, so they are required
and should not be removed. This is even mentioned in the comment block
above the initialization of mtd that you refer to: "The following
commands operate on the current device, _unless overridden by a
partition specifier_.".
Best regards,
Benoît
More information about the U-Boot
mailing list