[Qemu-devel] [PATCH] hw/ppc: use 0 instead of fdt_path_offset(fdt, "/")

Greg Kurz posted 1 patch 6 years, 6 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/150703999112.6139.714822137654210421.stgit@bahia.lab.toulouse-stg.fr.ibm.com
Test checkpatch passed
Test docker passed
Test s390x passed
hw/ppc/pnv.c   |    3 +--
hw/ppc/spapr.c |    3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
[Qemu-devel] [PATCH] hw/ppc: use 0 instead of fdt_path_offset(fdt, "/")
Posted by Greg Kurz 6 years, 6 months ago
The offset of the root node is guaranteed to be 0.

This doesn't fix anything, it's just trivial cleanup of the two
remaining places where this was done under hw/ppc.

Signed-off-by: Greg Kurz <groug@kaod.org>
---
 hw/ppc/pnv.c   |    3 +--
 hw/ppc/spapr.c |    3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index d46d91c76f5c..84b2389ea60b 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -92,8 +92,7 @@ static int get_cpus_node(void *fdt)
     int cpus_offset = fdt_path_offset(fdt, "/cpus");
 
     if (cpus_offset < 0) {
-        cpus_offset = fdt_add_subnode(fdt, fdt_path_offset(fdt, "/"),
-                                      "cpus");
+        cpus_offset = fdt_add_subnode(fdt, 0, "cpus");
         if (cpus_offset) {
             _FDT((fdt_setprop_cell(fdt, cpus_offset, "#address-cells", 0x1)));
             _FDT((fdt_setprop_cell(fdt, cpus_offset, "#size-cells", 0x0)));
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index ff87f155d55e..352ff3d614e8 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -353,8 +353,7 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineState *spapr)
 
         cpus_offset = fdt_path_offset(fdt, "/cpus");
         if (cpus_offset < 0) {
-            cpus_offset = fdt_add_subnode(fdt, fdt_path_offset(fdt, "/"),
-                                          "cpus");
+            cpus_offset = fdt_add_subnode(fdt, 0, "cpus");
             if (cpus_offset < 0) {
                 return cpus_offset;
             }


Re: [Qemu-devel] [PATCH] hw/ppc: use 0 instead of fdt_path_offset(fdt, "/")
Posted by Cédric Le Goater 6 years, 6 months ago
On 10/03/2017 04:13 PM, Greg Kurz wrote:
> The offset of the root node is guaranteed to be 0.
> 
> This doesn't fix anything, it's just trivial cleanup of the two
> remaining places where this was done under hw/ppc.
> 
> Signed-off-by: Greg Kurz <groug@kaod.org>

Looks good to me.

Reviewed-by: Cédric Le Goater <clg@kaod.org>

Thanks,

C.

> ---
>  hw/ppc/pnv.c   |    3 +--
>  hw/ppc/spapr.c |    3 +--
>  2 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
> index d46d91c76f5c..84b2389ea60b 100644
> --- a/hw/ppc/pnv.c
> +++ b/hw/ppc/pnv.c
> @@ -92,8 +92,7 @@ static int get_cpus_node(void *fdt)
>      int cpus_offset = fdt_path_offset(fdt, "/cpus");
>  
>      if (cpus_offset < 0) {
> -        cpus_offset = fdt_add_subnode(fdt, fdt_path_offset(fdt, "/"),
> -                                      "cpus");
> +        cpus_offset = fdt_add_subnode(fdt, 0, "cpus");
>          if (cpus_offset) {
>              _FDT((fdt_setprop_cell(fdt, cpus_offset, "#address-cells", 0x1)));
>              _FDT((fdt_setprop_cell(fdt, cpus_offset, "#size-cells", 0x0)));
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index ff87f155d55e..352ff3d614e8 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -353,8 +353,7 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineState *spapr)
>  
>          cpus_offset = fdt_path_offset(fdt, "/cpus");
>          if (cpus_offset < 0) {
> -            cpus_offset = fdt_add_subnode(fdt, fdt_path_offset(fdt, "/"),
> -                                          "cpus");
> +            cpus_offset = fdt_add_subnode(fdt, 0, "cpus");
>              if (cpus_offset < 0) {
>                  return cpus_offset;
>              }
> 


Re: [Qemu-devel] [Qemu-ppc] [PATCH] hw/ppc: use 0 instead of fdt_path_offset(fdt, "/")
Posted by Daniel Henrique Barboza 6 years, 6 months ago

On 10/03/2017 11:13 AM, Greg Kurz wrote:
> The offset of the root node is guaranteed to be 0.
>
> This doesn't fix anything, it's just trivial cleanup of the two
> remaining places where this was done under hw/ppc.
>
> Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>

> ---
>   hw/ppc/pnv.c   |    3 +--
>   hw/ppc/spapr.c |    3 +--
>   2 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
> index d46d91c76f5c..84b2389ea60b 100644
> --- a/hw/ppc/pnv.c
> +++ b/hw/ppc/pnv.c
> @@ -92,8 +92,7 @@ static int get_cpus_node(void *fdt)
>       int cpus_offset = fdt_path_offset(fdt, "/cpus");
>
>       if (cpus_offset < 0) {
> -        cpus_offset = fdt_add_subnode(fdt, fdt_path_offset(fdt, "/"),
> -                                      "cpus");
> +        cpus_offset = fdt_add_subnode(fdt, 0, "cpus");
>           if (cpus_offset) {
>               _FDT((fdt_setprop_cell(fdt, cpus_offset, "#address-cells", 0x1)));
>               _FDT((fdt_setprop_cell(fdt, cpus_offset, "#size-cells", 0x0)));
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index ff87f155d55e..352ff3d614e8 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -353,8 +353,7 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineState *spapr)
>
>           cpus_offset = fdt_path_offset(fdt, "/cpus");
>           if (cpus_offset < 0) {
> -            cpus_offset = fdt_add_subnode(fdt, fdt_path_offset(fdt, "/"),
> -                                          "cpus");
> +            cpus_offset = fdt_add_subnode(fdt, 0, "cpus");
>               if (cpus_offset < 0) {
>                   return cpus_offset;
>               }
>
>


Re: [Qemu-devel] [PATCH] hw/ppc: use 0 instead of fdt_path_offset(fdt, "/")
Posted by David Gibson 6 years, 6 months ago
On Tue, Oct 03, 2017 at 04:13:11PM +0200, Greg Kurz wrote:
> The offset of the root node is guaranteed to be 0.
> 
> This doesn't fix anything, it's just trivial cleanup of the two
> remaining places where this was done under hw/ppc.
> 
> Signed-off-by: Greg Kurz <groug@kaod.org>

Applied to ppc-for-2.11.

> ---
>  hw/ppc/pnv.c   |    3 +--
>  hw/ppc/spapr.c |    3 +--
>  2 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
> index d46d91c76f5c..84b2389ea60b 100644
> --- a/hw/ppc/pnv.c
> +++ b/hw/ppc/pnv.c
> @@ -92,8 +92,7 @@ static int get_cpus_node(void *fdt)
>      int cpus_offset = fdt_path_offset(fdt, "/cpus");
>  
>      if (cpus_offset < 0) {
> -        cpus_offset = fdt_add_subnode(fdt, fdt_path_offset(fdt, "/"),
> -                                      "cpus");
> +        cpus_offset = fdt_add_subnode(fdt, 0, "cpus");
>          if (cpus_offset) {
>              _FDT((fdt_setprop_cell(fdt, cpus_offset, "#address-cells", 0x1)));
>              _FDT((fdt_setprop_cell(fdt, cpus_offset, "#size-cells", 0x0)));
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index ff87f155d55e..352ff3d614e8 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -353,8 +353,7 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineState *spapr)
>  
>          cpus_offset = fdt_path_offset(fdt, "/cpus");
>          if (cpus_offset < 0) {
> -            cpus_offset = fdt_add_subnode(fdt, fdt_path_offset(fdt, "/"),
> -                                          "cpus");
> +            cpus_offset = fdt_add_subnode(fdt, 0, "cpus");
>              if (cpus_offset < 0) {
>                  return cpus_offset;
>              }
> 

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson