[U-Boot] [PATCH 2/2] env: Add back default action of get_char in env_get_char()

Simon Goldschmidt sgoldschmidt at de.pepperl-fuchs.com
Thu Feb 8 09:42:37 UTC 2018



[e-news abonnieren]<http://www.pepperl-fuchs.de/e-news> [YouTube: Pepperl+Fuchs auf YouTube] <http://www.youtube.com/user/PepperlFuchsGmbH>     [@PepperlFuchsDE folgen] <https://twitter.com/PepperlFuchsDE>   [Pepperl+Fuchs auf XING] <https://www.xing.com/companies/pepperl%252bfuchsgmbh>

________________________________
[Pepperl+Fuchs GmbH]<http://www.pepperl-fuchs.com>

Denken Sie bitte an die Umwelt und prüfen Sie, ob diese E-Mail wirklich ausgedruckt werden muss.

SocialMedia2014

On 08.02.2018 09:47, Maxime Ripard wrote:

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 at nxp.com><mailto:york.sun at nxp.com>
CC: Maxime Ripard <maxime.ripard at free-electrons.com><mailto:maxime.ripard at 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.

How can we decide which way is wanted? With your patch below, we might end up loading chars from a low-prio environment (which is not CRC checked) in the early boot stage. Later, we load the environment from another env driver with higher priority.

That's why I suggested removing the 'get_char' callback from the env drivers :-)
Early boot stage environment lookups would still work the old way reading from 'gd->env_addr + index'.

Simon


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





_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de<mailto:U-Boot at lists.denx.de>
https://lists.denx.de/listinfo/u-boot


-------------- next part --------------
A non-text attachment was scrubbed...
Name: image53adc6.BMP
Type: image/bmp
Size: 1782 bytes
Desc: image53adc6.BMP
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180208/9a583ce5/attachment-0005.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image90c3c9.BMP
Type: image/bmp
Size: 1782 bytes
Desc: image90c3c9.BMP
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180208/9a583ce5/attachment-0006.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image12d4d9.BMP
Type: image/bmp
Size: 1782 bytes
Desc: image12d4d9.BMP
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180208/9a583ce5/attachment-0007.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image518fd1.BMP
Type: image/bmp
Size: 1782 bytes
Desc: image518fd1.BMP
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180208/9a583ce5/attachment-0008.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: imagedae50d.BMP
Type: image/bmp
Size: 55350 bytes
Desc: imagedae50d.BMP
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180208/9a583ce5/attachment-0009.bin>


More information about the U-Boot mailing list