diff mbox series

cmd: fdt: Drop the 0x prefix

Message ID 20230302030440.322361-1-marek.vasut+renesas@mailbox.org
State Accepted
Commit ed4dcb1f9b12e84721f70cc0a9bf838059581967
Delegated to: Simon Glass
Headers show
Series cmd: fdt: Drop the 0x prefix | expand

Commit Message

Marek Vasut March 2, 2023, 3:04 a.m. UTC
The 'fdt get addr' is always assumed to be hex value, drop the prefix.
Since this might break existing users who depend on the existing
behavior with 0x prefix, this is a separate patch. Revert if this
breaks anything.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
---
Cc: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
---
 cmd/fdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Glass March 6, 2023, 5:53 p.m. UTC | #1
Hi Marek,

On Wed, 1 Mar 2023 at 20:04, Marek Vasut
<marek.vasut+renesas@mailbox.org> wrote:
>
> The 'fdt get addr' is always assumed to be hex value, drop the prefix.
> Since this might break existing users who depend on the existing
> behavior with 0x prefix, this is a separate patch. Revert if this
> breaks anything.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
> ---
> Cc: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> ---
>  cmd/fdt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/cmd/fdt.c b/cmd/fdt.c
> index f38fe909c3e..04b664e652c 100644
> --- a/cmd/fdt.c
> +++ b/cmd/fdt.c
> @@ -478,7 +478,7 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
>                                         /* Get address */
>                                         char buf[19];
>
> -                                       snprintf(buf, sizeof(buf), "0x%lx",
> +                                       snprintf(buf, sizeof(buf), "%lx",
>                                                  (ulong)map_to_sysmem(nodep));
>                                         env_set(var, buf);
>                                 } else if (subcmd[0] == 's') {
> --
> 2.39.2
>

iwc how about using env_sethex() ?

Regards,
Simon
Marek Vasut March 6, 2023, 7:06 p.m. UTC | #2
On 3/6/23 18:53, Simon Glass wrote:
> Hi Marek,
> 
> On Wed, 1 Mar 2023 at 20:04, Marek Vasut
> <marek.vasut+renesas@mailbox.org> wrote:
>>
>> The 'fdt get addr' is always assumed to be hex value, drop the prefix.
>> Since this might break existing users who depend on the existing
>> behavior with 0x prefix, this is a separate patch. Revert if this
>> breaks anything.
>>
>> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
>> ---
>> Cc: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
>> Cc: Simon Glass <sjg@chromium.org>
>> Cc: Tom Rini <trini@konsulko.com>
>> ---
>>   cmd/fdt.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/cmd/fdt.c b/cmd/fdt.c
>> index f38fe909c3e..04b664e652c 100644
>> --- a/cmd/fdt.c
>> +++ b/cmd/fdt.c
>> @@ -478,7 +478,7 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
>>                                          /* Get address */
>>                                          char buf[19];
>>
>> -                                       snprintf(buf, sizeof(buf), "0x%lx",
>> +                                       snprintf(buf, sizeof(buf), "%lx",
>>                                                   (ulong)map_to_sysmem(nodep));
>>                                          env_set(var, buf);
>>                                  } else if (subcmd[0] == 's') {
>> --
>> 2.39.2
>>
> 
> iwc how about using env_sethex() ?

The 'env get size' 's' case below could likely use similar treatment , 
do I read it right ?
Simon Glass March 6, 2023, 11:23 p.m. UTC | #3
Hi Marek,

On Mon, 6 Mar 2023 at 12:07, Marek Vasut <marek.vasut@mailbox.org> wrote:
>
> On 3/6/23 18:53, Simon Glass wrote:
> > Hi Marek,
> >
> > On Wed, 1 Mar 2023 at 20:04, Marek Vasut
> > <marek.vasut+renesas@mailbox.org> wrote:
> >>
> >> The 'fdt get addr' is always assumed to be hex value, drop the prefix.
> >> Since this might break existing users who depend on the existing
> >> behavior with 0x prefix, this is a separate patch. Revert if this
> >> breaks anything.
> >>
> >> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
> >> ---
> >> Cc: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> >> Cc: Simon Glass <sjg@chromium.org>
> >> Cc: Tom Rini <trini@konsulko.com>
> >> ---
> >>   cmd/fdt.c | 2 +-
> >>   1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/cmd/fdt.c b/cmd/fdt.c
> >> index f38fe909c3e..04b664e652c 100644
> >> --- a/cmd/fdt.c
> >> +++ b/cmd/fdt.c
> >> @@ -478,7 +478,7 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
> >>                                          /* Get address */
> >>                                          char buf[19];
> >>
> >> -                                       snprintf(buf, sizeof(buf), "0x%lx",
> >> +                                       snprintf(buf, sizeof(buf), "%lx",
> >>                                                   (ulong)map_to_sysmem(nodep));
> >>                                          env_set(var, buf);
> >>                                  } else if (subcmd[0] == 's') {
> >> --
> >> 2.39.2
> >>
> >
> > iwc how about using env_sethex() ?
>
> The 'env get size' 's' case below could likely use similar treatment ,
> do I read it right ?

Yes...I think the helpers were added more recently than this code.

Regards,
Simon
Simon Glass March 10, 2023, 4:11 p.m. UTC | #4
Hi Marek,

On Mon, 6 Mar 2023 at 12:07, Marek Vasut <marek.vasut@mailbox.org> wrote:
>
> On 3/6/23 18:53, Simon Glass wrote:
> > Hi Marek,
> >
> > On Wed, 1 Mar 2023 at 20:04, Marek Vasut
> > <marek.vasut+renesas@mailbox.org> wrote:
> >>
> >> The 'fdt get addr' is always assumed to be hex value, drop the prefix.
> >> Since this might break existing users who depend on the existing
> >> behavior with 0x prefix, this is a separate patch. Revert if this
> >> breaks anything.
> >>
> >> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
> >> ---
> >> Cc: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> >> Cc: Simon Glass <sjg@chromium.org>
> >> Cc: Tom Rini <trini@konsulko.com>
> >> ---
> >>   cmd/fdt.c | 2 +-
> >>   1 file changed, 1 insertion(+), 1 deletion(-)
> >>
Applied to u-boot-dm/next, thanks!
diff mbox series

Patch

diff --git a/cmd/fdt.c b/cmd/fdt.c
index f38fe909c3e..04b664e652c 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -478,7 +478,7 @@  static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 					/* Get address */
 					char buf[19];
 
-					snprintf(buf, sizeof(buf), "0x%lx",
+					snprintf(buf, sizeof(buf), "%lx",
 						 (ulong)map_to_sysmem(nodep));
 					env_set(var, buf);
 				} else if (subcmd[0] == 's') {