From mboxrd@z Thu Jan 1 00:00:00 1970 From: Scott Wood Date: Wed, 21 Sep 2011 13:55:40 -0500 Subject: [U-Boot] [PATCH 4/5] NAND: Make page, erase, oob size available via cmd_nand In-Reply-To: <1315800250-19761-5-git-send-email-marek.vasut@gmail.com> References: <1315800250-19761-1-git-send-email-marek.vasut@gmail.com> <1315800250-19761-5-git-send-email-marek.vasut@gmail.com> Message-ID: <4E7A332C.5000705@freescale.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 > Cc: Scott Wood > Cc: Stefano Babic > Cc: Wolfgang Denk > Cc: Detlev Zundel > --- > 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 > #include > #include > +#ifdef CONFIG_SYS_HUSH_PARSER > +#include > +#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