cmd_nand: fix a memory leak in nand_dump function

If datbuf = memalign(ARCH_DMA_MINALIGN, nand->writesize);
succeeds and
  oobbuf = memalign(ARCH_DMA_MINALIGN, nand->oobsize);
fails, nand_dump function should free databuf.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
cmd_nand: slight optimization of nand_dump function

If a non-zero value is given to only_oob argument,
printing the main area is skipped.

With a little modification, we can skip the whole
while loop.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
cmd_nand: Do not show usage when scrub is aborted

When executing nand scrub, the user gets the prompt:

  Really scrub this NAND flash? <y/N>

We do not want the annoying usage displayed when saying N here.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
nand_util: delete a useless variable

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
env_nand.c: support falling back to redundant env when writing

Without this patch, when the currently chosen environment to be written
has bad blocks, saveenv fails completely. Instead, when there is
redundant environment fall back to the other copy. Environment reading
needs no adjustment, as the fallback logic for incomplete writes applies
to this case as well.

Signed-off-by: Phil Sutter <phil.sutter@viprinet.com>