[U-Boot] [PATCH 4/5] NAND: Make page, erase, oob size available via cmd_nand
Scott Wood
scottwood at freescale.com
Wed Sep 21 20:55:40 CEST 2011
On 09/11/2011 11:04 PM, Marek Vasut wrote:
> The "nand info" and "nand device" now set shell/environment variables:
> nand_writesize ... nand page size
> nand_oobsize ..... nand oob area size
> nand_erasesize ... nand erase block size
>
> The shell variables are only set if HUSH is enabled.
>
> Also, the "nand info" command now displays this info.
"writesize" is what the internals use for this, but nand_pagesize would
be more obvious.
> Signed-off-by: Marek Vasut <marek.vasut at gmail.com>
> Cc: Scott Wood <scottwood at freescale.com>
> Cc: Stefano Babic <sbabic at denx.de>
> Cc: Wolfgang Denk <wd at denx.de>
> Cc: Detlev Zundel <dzu at denx.de>
> ---
> common/cmd_nand.c | 42 +++++++++++++++++++++++++++++++++++++++---
> 1 files changed, 39 insertions(+), 3 deletions(-)
>
> diff --git a/common/cmd_nand.c b/common/cmd_nand.c
> index a1c8dfd..5b7e83d 100644
> --- a/common/cmd_nand.c
> +++ b/common/cmd_nand.c
> @@ -27,6 +27,9 @@
> #include <asm/byteorder.h>
> #include <jffs2/jffs2.h>
> #include <nand.h>
> +#ifdef CONFIG_SYS_HUSH_PARSER
> +#include <hush.h>
> +#endif
I don't think you need this ifdef.
> + /* Set geometry info */
> +#ifdef CONFIG_SYS_HUSH_PARSER
> + memset(buf, 0, bufsz);
> + sprintf(buf, "nand_writesize=%x", nand->writesize);
> + set_local_var(buf, 0);
> +
> + memset(buf, 0, bufsz);
> + sprintf(buf, "nand_oobsize=%x", nand->oobsize);
> + set_local_var(buf, 0);
> +
> + memset(buf, 0, bufsz);
> + sprintf(buf, "nand_erasesize=%x", nand->erasesize);
> + set_local_var(buf, 0);
> +#else
> + memset(buf, 0, bufsz);
> + sprintf(buf, "%x", nand->writesize);
> + setenv("nand_writesize", buf);
> +
> + memset(buf, 0, bufsz);
> + sprintf(buf, "%x", nand->oobsize);
> + setenv("nand_oobsize", buf);
> +
> + memset(buf, 0, bufsz);
> + sprintf(buf, "%x", nand->erasesize);
> + setenv("nand_erasesize", buf);
> +#endif
Is there no existing abstraction to add a variable to both the shell (if
present) and the environment, without needing such an ifdef in the
caller? If not, should one be added?
-Scott
More information about the U-Boot
mailing list