[PATCH 2/5] hw/loongarch: Use hex unit addresses in FDT CPU nodes

Vivian Wang posted 5 patches 2 days, 10 hours ago
Maintainers: Peter Maydell <peter.maydell@linaro.org>, Leif Lindholm <leif.lindholm@oss.qualcomm.com>, Song Gao <gaosong@loongson.cn>, Bibo Mao <maobibo@loongson.cn>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Paul Burton <paulburton@kernel.org>, Aleksandar Rikalo <arikalo@gmail.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Jia Liu <proljc@gmail.com>, Stafford Horne <shorne@gmail.com>, Alistair Francis <Alistair.Francis@wdc.com>, Palmer Dabbelt <palmer@dabbelt.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>, Chao Liu <chao.liu.zevorn@gmail.com>
[PATCH 2/5] hw/loongarch: Use hex unit addresses in FDT CPU nodes
Posted by Vivian Wang 2 days, 10 hours ago
These unit addresses should have been in hex, not decimal, as per de
facto convention [1]. Fix them.

Link: https://lore.kernel.org/devicetree-spec/CAL_JsqJFv3+UJ-bjLGk0i7Wc+spsowCrqQZ_s3P4gN8r1W-Q-w@mail.gmail.com/ # [1]
Signed-off-by: Vivian Wang <wangruikang@iscas.ac.cn>
---
 hw/loongarch/virt-fdt-build.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/loongarch/virt-fdt-build.c b/hw/loongarch/virt-fdt-build.c
index 6c06b36fca..5875c6d9ae 100644
--- a/hw/loongarch/virt-fdt-build.c
+++ b/hw/loongarch/virt-fdt-build.c
@@ -66,7 +66,7 @@ static void fdt_add_cpu_nodes(const LoongArchVirtMachineState *lvms)
             continue;
         }
 
-        nodename = g_strdup_printf("/cpus/cpu@%d", num);
+        nodename = g_strdup_printf("/cpus/cpu@%x", (unsigned)num);
         cpu = LOONGARCH_CPU(cs);
 
         qemu_fdt_add_subnode(ms->fdt, nodename);
@@ -91,7 +91,7 @@ static void fdt_add_cpu_nodes(const LoongArchVirtMachineState *lvms)
             continue;
         }
 
-        nodename = g_strdup_printf("/cpus/cpu@%d", num);
+        nodename = g_strdup_printf("/cpus/cpu@%x", (unsigned)num);
         if (ms->smp.threads > 1) {
             map_path = g_strdup_printf(
                 "/cpus/cpu-map/socket%d/core%d/thread%d",

-- 
2.53.0
Re: [PATCH 2/5] hw/loongarch: Use hex unit addresses in FDT CPU nodes
Posted by Philippe Mathieu-Daudé 2 days, 7 hours ago
On 9/4/26 08:40, Vivian Wang wrote:
> These unit addresses should have been in hex, not decimal, as per de
> facto convention [1]. Fix them.
> 
> Link: https://lore.kernel.org/devicetree-spec/CAL_JsqJFv3+UJ-bjLGk0i7Wc+spsowCrqQZ_s3P4gN8r1W-Q-w@mail.gmail.com/ # [1]
> Signed-off-by: Vivian Wang <wangruikang@iscas.ac.cn>
> ---
>   hw/loongarch/virt-fdt-build.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/loongarch/virt-fdt-build.c b/hw/loongarch/virt-fdt-build.c
> index 6c06b36fca..5875c6d9ae 100644
> --- a/hw/loongarch/virt-fdt-build.c
> +++ b/hw/loongarch/virt-fdt-build.c
> @@ -66,7 +66,7 @@ static void fdt_add_cpu_nodes(const LoongArchVirtMachineState *lvms)
>               continue;
>           }
>   
> -        nodename = g_strdup_printf("/cpus/cpu@%d", num);
> +        nodename = g_strdup_printf("/cpus/cpu@%x", (unsigned)num);

No need to cast to unsigned explicitly, otherwise:
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>