From: Maxime Ripard <maxime.ripard@bootlin.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/2] env: Add back default action of get_char in env_get_char()
Date: Thu, 8 Feb 2018 09:47:21 +0100 [thread overview]
Message-ID: <20180208084721.zpygkcprcmce4hfo@flea> (raw)
In-Reply-To: <1518041832-337-2-git-send-email-york.sun@nxp.com>
On Wed, Feb 07, 2018 at 02:17:12PM -0800, York Sun wrote:
> Commit 8a3a7e2270b3 ("env: Pass additional parameters to the env
> lookup function") dropped the default action if driver doesn't have
> get_char() defined. This causes failure to get environmental
> variables from NOR flash. Add back this default action for now.
>
> Signed-off-by: York Sun <york.sun@nxp.com>
> CC: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
> Limited test on LS1043ARDB.
>
> env/env.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/env/env.c b/env/env.c
> index edfb575..210bae2 100644
> --- a/env/env.c
> +++ b/env/env.c
> @@ -159,7 +159,7 @@ int env_get_char(int index)
> int ret;
>
> if (!drv->get_char)
> - continue;
> + return *(uchar *)(gd->env_addr + index);
Thinking more about this, I think this would break the case where the
first environment in your list has no get_char method, but the second
might.
Would something like that work?
------------ 8< --------
diff --git a/env/env.c b/env/env.c
index 9a89832c1aaf..391c9c0df2f0 100644
--- a/env/env.c
+++ b/env/env.c
@@ -152,6 +152,7 @@ static struct env_driver *env_driver_lookup(enum env_operation op, int prio)
int env_get_char(int index)
{
struct env_driver *drv;
+ bool has_get_char = false;
int prio;
if (gd->env_valid == ENV_INVALID)
@@ -166,6 +167,7 @@ int env_get_char(int index)
if (!env_has_inited(drv->location))
continue;
+ has_get_char = true;
ret = drv->get_char(index);
if (!ret)
return 0;
@@ -174,6 +176,9 @@ int env_get_char(int index)
drv->name, ret);
}
+ if (!has_get_char)
+ return *(uchar *)(gd->env_addr + index);
+
return -ENODEV;
}
------ 8< -------
Thanks!
Maxime
--
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180208/3a4fb80f/attachment.sig>
next prev parent reply other threads:[~2018-02-08 8:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-07 22:17 [U-Boot] [PATCH 1/2] env: Fix env_load_location York Sun
2018-02-07 22:17 ` [U-Boot] [PATCH 2/2] env: Add back default action of get_char in env_get_char() York Sun
2018-02-08 8:47 ` Maxime Ripard [this message]
2018-02-08 9:42 ` Simon Goldschmidt
2018-02-08 9:43 ` Simon Goldschmidt
2018-02-08 9:52 ` Simon Goldschmidt
2018-02-08 22:10 ` Maxime Ripard
2018-02-09 20:25 ` Goldschmidt Simon
2018-02-08 8:38 ` [U-Boot] [PATCH 1/2] env: Fix env_load_location Maxime Ripard
2018-02-08 10:05 ` Simon Goldschmidt
2018-02-08 19:28 ` York Sun
2018-02-17 20:51 ` [U-Boot] [U-Boot,1/2] " Tom Rini
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=20180208084721.zpygkcprcmce4hfo@flea \
--to=maxime.ripard@bootlin.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