[U-Boot] [PATCH] common/memsize.c: fix endless loop when saving
Eddy Petrișor
eddy.petrisor at gmail.com
Tue Feb 9 18:55:08 CET 2016
2016-02-09 19:41 GMT+02:00 Eddy Petrișor <eddy.petrisor at nxp.com>:
> When cnt reaches 0, any shift operation will keep cnt=0, so the condition
> `cnt >= 0` doesn't make sense.
>
> To fix this endless loop, we drop the useless condition and simply break the
> loop when cnt reaches 0.
This should fix the endless issue introduced by the previous patch
8e7cba048baae68ee0916a8f52b4304277328d5e
Hannes, can you confirm that with this patch the reported size is
correct and the boot is normal again?
I initially thought the size might be incorret due to some buggy HW I
have (it has some unstable DDR settings, which lead to incorrect
reports on my side initially).
> Signed-off-by: Eddy Petrișor <eddy.petrisor at nxp.com>
> ---
> common/memsize.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/common/memsize.c b/common/memsize.c
> index 5c0d279..a6af993 100644
> --- a/common/memsize.c
> +++ b/common/memsize.c
> @@ -33,7 +33,7 @@ long get_ram_size(long *base, long maxsize)
> long size;
> int i = 0;
>
> - for (cnt = (maxsize / sizeof(long)) >> 1; cnt >= 0; cnt >>= 1) {
> + for (cnt = (maxsize / sizeof(long)) >> 1; ; cnt >>= 1) {
> addr = base + cnt; /* pointer arith! */
> sync();
> save[i] = *addr;
> @@ -43,6 +43,7 @@ long get_ram_size(long *base, long maxsize)
> *addr = ~cnt;
> } else {
> *addr = 0;
> + break;
> }
> }
>
> --
> 1.9.2.459.g68773ac
>
--
Eddy Petrișor
More information about the U-Boot
mailing list