qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
To: Ying Fang <fangying1@huawei.com>
Cc: peter.maydell@linaro.org, salil.mehta@huawei.com,
	zhang.zhanghailiang@huawei.com, mst@redhat.com,
	qemu-devel@nongnu.org, shannon.zhaosl@gmail.com,
	qemu-arm@nongnu.org, alistair.francis@wdc.com,
	imammedo@redhat.com
Subject: Re: [RFC PATCH 1/5] device_tree: Add qemu_fdt_add_path
Date: Thu, 25 Feb 2021 12:03:11 +0100	[thread overview]
Message-ID: <20210225110311.quvchs32o4n6iqpt@kamzik.brq.redhat.com> (raw)
In-Reply-To: <20210225085627.2263-2-fangying1@huawei.com>

Hi Ying Fang,

I don't see any change in this patch from what I have in my
tree, so this should be

 From: Andrew Jones <drjones@redhat.com>

Thanks,
drew

On Thu, Feb 25, 2021 at 04:56:23PM +0800, Ying Fang wrote:
> qemu_fdt_add_path() works like qemu_fdt_add_subnode(), except
> it also adds any missing parent nodes. We also tweak an error
> message of qemu_fdt_add_subnode().
> 
> Signed-off-by: Andrew Jones <drjones@redhat.com>
> Signed-off-by: Ying Fang <fangying1@huawei.com>
> ---
>  include/sysemu/device_tree.h |  1 +
>  softmmu/device_tree.c        | 45 ++++++++++++++++++++++++++++++++++--
>  2 files changed, 44 insertions(+), 2 deletions(-)
> 
> diff --git a/include/sysemu/device_tree.h b/include/sysemu/device_tree.h
> index 982c89345f..15fb98af98 100644
> --- a/include/sysemu/device_tree.h
> +++ b/include/sysemu/device_tree.h
> @@ -104,6 +104,7 @@ uint32_t qemu_fdt_get_phandle(void *fdt, const char *path);
>  uint32_t qemu_fdt_alloc_phandle(void *fdt);
>  int qemu_fdt_nop_node(void *fdt, const char *node_path);
>  int qemu_fdt_add_subnode(void *fdt, const char *name);
> +int qemu_fdt_add_path(void *fdt, const char *path);
>  
>  #define qemu_fdt_setprop_cells(fdt, node_path, property, ...)                 \
>      do {                                                                      \
> diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c
> index b9a3ddc518..1e3857ca0c 100644
> --- a/softmmu/device_tree.c
> +++ b/softmmu/device_tree.c
> @@ -515,8 +515,8 @@ int qemu_fdt_add_subnode(void *fdt, const char *name)
>  
>      retval = fdt_add_subnode(fdt, parent, basename);
>      if (retval < 0) {
> -        error_report("FDT: Failed to create subnode %s: %s", name,
> -                     fdt_strerror(retval));
> +        error_report("%s: Failed to create subnode %s: %s",
> +                     __func__, name, fdt_strerror(retval));
>          exit(1);
>      }
>  
> @@ -524,6 +524,47 @@ int qemu_fdt_add_subnode(void *fdt, const char *name)
>      return retval;
>  }
>  
> +/*
> + * Like qemu_fdt_add_subnode(), but will add all missing
> + * subnodes in the path.
> + */
> +int qemu_fdt_add_path(void *fdt, const char *path)
> +{
> +    char *dupname, *basename, *p;
> +    int parent, retval = -1;
> +
> +    if (path[0] != '/') {
> +        return retval;
> +    }
> +
> +    parent = fdt_path_offset(fdt, "/");
> +    p = dupname = g_strdup(path);
> +
> +    while (p) {
> +        *p = '/';
> +        basename = p + 1;
> +        p = strchr(p + 1, '/');
> +        if (p) {
> +            *p = '\0';
> +        }
> +        retval = fdt_path_offset(fdt, dupname);
> +        if (retval < 0 && retval != -FDT_ERR_NOTFOUND) {
> +            error_report("%s: Invalid path %s: %s",
> +                         __func__, path, fdt_strerror(retval));
> +            exit(1);
> +        } else if (retval == -FDT_ERR_NOTFOUND) {
> +            retval = fdt_add_subnode(fdt, parent, basename);
> +            if (retval < 0) {
> +                break;
> +            }
> +        }
> +        parent = retval;
> +    }
> +
> +    g_free(dupname);
> +    return retval;
> +}
> +
>  void qemu_fdt_dumpdtb(void *fdt, int size)
>  {
>      const char *dumpdtb = current_machine->dumpdtb;
> -- 
> 2.23.0
> 
> 



  reply	other threads:[~2021-02-25 11:18 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-25  8:56 [RFC PATCH 0/5] hw/arm/virt: Introduce cpu topology support Ying Fang
2021-02-25  8:56 ` [RFC PATCH 1/5] device_tree: Add qemu_fdt_add_path Ying Fang
2021-02-25 11:03   ` Andrew Jones [this message]
2021-02-25 12:54     ` Ying Fang
2021-02-25 13:25       ` Andrew Jones
2021-02-25 13:39         ` Ying Fang
2021-02-25  8:56 ` [RFC PATCH 2/5] hw/arm/virt: Add cpu-map to device tree Ying Fang
2021-02-25 11:16   ` Andrew Jones
2021-02-25 13:18     ` Ying Fang
2021-02-25 14:30       ` Andrew Jones
2021-02-25  8:56 ` [RFC PATCH 3/5] hw/arm/virt-acpi-build: distinguish possible and present cpus Ying Fang
2021-02-25 11:26   ` Andrew Jones
2021-02-25  8:56 ` [RFC PATCH 4/5] hw/acpi/aml-build: add processor hierarchy node structure Ying Fang
2021-02-25 11:47   ` Andrew Jones
2021-02-26  2:23     ` Ying Fang
2021-03-01  9:39       ` Andrew Jones
2021-03-01 15:50         ` Michael S. Tsirkin
2021-03-04  7:09           ` Ying Fang
2021-02-25  8:56 ` [RFC PATCH 5/5] hw/arm/virt-acpi-build: add PPTT table Ying Fang
2021-02-25 11:38   ` Andrew Jones
2021-02-26  2:26     ` Ying Fang
2021-02-25 12:02 ` [RFC PATCH 0/5] hw/arm/virt: Introduce cpu topology support Andrew Jones
2021-02-26  8:41   ` Ying Fang
2021-03-01  9:48     ` Andrew Jones
2021-03-05  6:14       ` Ying Fang
     [not found] ` <20210310092059.blt3yymqi2eyc2ua@kamzik.brq.redhat.com>
2021-03-10  9:43   ` 答复: " fangying

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210225110311.quvchs32o4n6iqpt@kamzik.brq.redhat.com \
    --to=drjones@redhat.com \
    --cc=alistair.francis@wdc.com \
    --cc=fangying1@huawei.com \
    --cc=imammedo@redhat.com \
    --cc=mst@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=salil.mehta@huawei.com \
    --cc=shannon.zhaosl@gmail.com \
    --cc=zhang.zhanghailiang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).