public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] nand: mxs_nand_spl: support use of env in SPL
Date: Thu, 14 May 2015 13:10:55 -0500	[thread overview]
Message-ID: <1431627055.3868.180.camel@freescale.com> (raw)
In-Reply-To: <CAJ+vNU3+HRTwqhkzXKuyORbGB01Lv-9n0E7xmoGsVhSB5xXCOw@mail.gmail.com>

On Thu, 2015-05-14 at 08:12 -0700, Tim Harvey wrote:
> It turns out that this is needed because env_nand.c:readenv() calls
> nand_read_skip_bad, which uses the mtd layer. For SPL the
> functionality of readenv() is pretty much already in
> nand_spl_load_image() so I find if do the following (instead of making
> any changes to mxs_nand_spl.c) which allows the mtd layers to not be
> used I save 4KB in the SPL:
> 
> diff --git a/common/env_nand.c b/common/env_nand.c
> index cc7e979..97d10a2 100644
> --- a/common/env_nand.c
> +++ b/common/env_nand.c
> @@ -260,6 +260,9 @@ int saveenv(void)
>  }
>  #endif /* CMD_SAVEENV */
> 
> +#if defined(CONFIG_SPL_BUILD)
> +#define readenv(offset, buf) nand_spl_load_image(offset, CONFIG_ENV_SIZE, buf)
> +#else
>  static int readenv(size_t offset, u_char *buf)
>  {
>         size_t end = offset + CONFIG_ENV_RANGE;
> @@ -295,6 +298,7 @@ static int readenv(size_t offset, u_char *buf)
> 
>         return 0;
>  }
> +#endif /* #if defined(CONFIG_SPL_BUILD) */
> 
>  #ifdef CONFIG_ENV_OFFSET_OOB
>  int get_nand_env_oob(nand_info_t *nand, unsigned long *result)
> 
> I don't think I'm loosing any necessary functionality in the SPL by
> doing the above and it saves me 4KB in the SPL which is precious
> space.

I'd prefer a function over a macro, but OK.

readenv() itself looks like it could be greatly simplified by dropping
the loop and bad block check, since nand_read_skip_bad() handles that.

-Scott

      reply	other threads:[~2015-05-14 18:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-08 21:39 [U-Boot] [PATCH] nand: mxs_nand_spl: support use of env in SPL Tim Harvey
2015-05-13 16:56 ` Tim Harvey
2015-05-13 23:38 ` Scott Wood
2015-05-14 15:12   ` Tim Harvey
2015-05-14 18:10     ` Scott Wood [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1431627055.3868.180.camel@freescale.com \
    --to=scottwood@freescale.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox