* [PATCH] board/km: fix setting of pram variable
@ 2021-02-05 9:55 Holger Brunck
2021-02-05 10:11 ` Stefan Roese
0 siblings, 1 reply; 3+ messages in thread
From: Holger Brunck @ 2021-02-05 9:55 UTC (permalink / raw)
To: u-boot
The pram variable is evaluated in common/board_r.c as a unsigned long
and not as a string using a hex formataion. This incorrect setting
leads to a wrong calculation of preserved RAM for u-boot. This is fixed
now. The pram variable is now a unsigned long specifying the amount of
kB of preserved RAM.
Signed-off-by: Holger Brunck <holger.brunck@hitachi-powergrids.com>
CC: Stefan Roese <sr@denx.de>
---
board/keymile/common/common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c
index df507e2..7343d47 100644
--- a/board/keymile/common/common.c
+++ b/board/keymile/common/common.c
@@ -60,7 +60,7 @@ int set_km_env(void)
strict_strtoul(p, 16, &rootfssize);
pram = (rootfssize + CONFIG_KM_RESERVED_PRAM + CONFIG_KM_PHRAM +
CONFIG_KM_PNVRAM) / 0x400;
- sprintf((char *)buf, "0x%x", pram);
+ sprintf((char *)buf, "%u", pram);
env_set("pram", (char *)buf);
varaddr = gd->ram_size - CONFIG_KM_RESERVED_PRAM - CONFIG_KM_PHRAM;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] board/km: fix setting of pram variable
2021-02-05 9:55 [PATCH] board/km: fix setting of pram variable Holger Brunck
@ 2021-02-05 10:11 ` Stefan Roese
2021-02-05 10:16 ` Holger Brunck
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Roese @ 2021-02-05 10:11 UTC (permalink / raw)
To: u-boot
(Added Niel to Cc)
On 05.02.21 10:55, Holger Brunck wrote:
> The pram variable is evaluated in common/board_r.c as a unsigned long
> and not as a string using a hex formataion. This incorrect setting
> leads to a wrong calculation of preserved RAM for u-boot. This is fixed
> now. The pram variable is now a unsigned long specifying the amount of
> kB of preserved RAM.
>
> Signed-off-by: Holger Brunck <holger.brunck@hitachi-powergrids.com>
> CC: Stefan Roese <sr@denx.de>
> ---
> board/keymile/common/common.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c
> index df507e2..7343d47 100644
> --- a/board/keymile/common/common.c
> +++ b/board/keymile/common/common.c
> @@ -60,7 +60,7 @@ int set_km_env(void)
> strict_strtoul(p, 16, &rootfssize);
> pram = (rootfssize + CONFIG_KM_RESERVED_PRAM + CONFIG_KM_PHRAM +
> CONFIG_KM_PNVRAM) / 0x400;
> - sprintf((char *)buf, "0x%x", pram);
> + sprintf((char *)buf, "%u", pram);
> env_set("pram", (char *)buf);
I've commented to Niel as well before:
Why don't you switch to using a different env_set_foo() API instead?
Like env_set_ulong() in this case? Or env_set_hex() in the HEX case.
This could also be done for some other env_set cases in this file as
well to reduce code size and complexity.
Thanks,
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] board/km: fix setting of pram variable
2021-02-05 10:11 ` Stefan Roese
@ 2021-02-05 10:16 ` Holger Brunck
0 siblings, 0 replies; 3+ messages in thread
From: Holger Brunck @ 2021-02-05 10:16 UTC (permalink / raw)
To: u-boot
Hi Stefan,
>
> (Added Niel to Cc)
>
> On 05.02.21 10:55, Holger Brunck wrote:
> > The pram variable is evaluated in common/board_r.c as a unsigned long
> > and not as a string using a hex formataion. This incorrect setting
> > leads to a wrong calculation of preserved RAM for u-boot. This is
> > fixed now. The pram variable is now a unsigned long specifying the
> > amount of kB of preserved RAM.
> >
> > Signed-off-by: Holger Brunck <holger.brunck@hitachi-powergrids.com>
> > CC: Stefan Roese <sr@denx.de>
> > ---
> > board/keymile/common/common.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/board/keymile/common/common.c
> > b/board/keymile/common/common.c index df507e2..7343d47 100644
> > --- a/board/keymile/common/common.c
> > +++ b/board/keymile/common/common.c
> > @@ -60,7 +60,7 @@ int set_km_env(void)
> > strict_strtoul(p, 16, &rootfssize);
> > pram = (rootfssize + CONFIG_KM_RESERVED_PRAM +
> CONFIG_KM_PHRAM +
> > CONFIG_KM_PNVRAM) / 0x400;
> > - sprintf((char *)buf, "0x%x", pram);
> > + sprintf((char *)buf, "%u", pram);
> > env_set("pram", (char *)buf);
>
> I've commented to Niel as well before:
>
> Why don't you switch to using a different env_set_foo() API instead?
> Like env_set_ulong() in this case? Or env_set_hex() in the HEX case.
> This could also be done for some other env_set cases in this file as well to
> reduce code size and complexity.
>
You are right. And I just saw now that Niel is already doing this in
[v2,2/3] keymile: common: update to set_env_hex(), fix "pram" radix
which is still under review.
So this patch can be abandoned.
Best regards
Holger
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-05 10:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-05 9:55 [PATCH] board/km: fix setting of pram variable Holger Brunck
2021-02-05 10:11 ` Stefan Roese
2021-02-05 10:16 ` Holger Brunck
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.