All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/6] fdtdec: Implement fdtdec_set_phandle()
Date: Sun, 10 Mar 2019 15:51:40 -0600	[thread overview]
Message-ID: <CAPnjgZ3hzk6uLOgaEZSk=M=quAKSZ6FVOvfuyELSe8-0O_ndKA@mail.gmail.com> (raw)
In-Reply-To: <20190308201140.2383-3-thierry.reding@gmail.com>

Hi Thierry,

On Fri, 8 Mar 2019 at 13:11, Thierry Reding <thierry.reding@gmail.com> wrote:
>
> From: Thierry Reding <treding@nvidia.com>
>
> This function can be used to set a phandle for a given node.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  include/fdtdec.h | 11 +++++++++++
>  lib/fdtdec.c     | 16 ++++++++++++++++
>  2 files changed, 27 insertions(+)

This seems OK, although I think it should have a test.

But what about livetree? I think it would make more sense to add a
high-level API which can deal with livetree/flattree.

>
> diff --git a/include/fdtdec.h b/include/fdtdec.h
> index 5eb3c0c237a9..997103a87cdf 100644
> --- a/include/fdtdec.h
> +++ b/include/fdtdec.h
> @@ -968,6 +968,17 @@ int fdtdec_setup_memory_banksize(void);
>   */
>  int fdtdec_get_max_phandle(const void *blob, uint32_t *maxp);
>
> +/**
> + * fdtdec_set_phandle() - sets the phandle of a given node
> + *
> + * @param blob         FDT blob
> + * @param node         offset in the FDT blob of the node whose phandle is to
> + *                     be set
> + * @param phandle      phandle to set for the given node
> + * @return 0 on success or a negative error code on failure
> + */
> +int fdtdec_set_phandle(void *blob, int node, uint32_t phandle);
> +
>  /**
>   * Set up the device tree ready for use
>   */
> diff --git a/lib/fdtdec.c b/lib/fdtdec.c
> index f2af947c106e..9195a05d1129 100644
> --- a/lib/fdtdec.c
> +++ b/lib/fdtdec.c
> @@ -1271,6 +1271,22 @@ int fdtdec_get_max_phandle(const void *blob, uint32_t *maxp)
>         return 0;
>  }
>
> +int fdtdec_set_phandle(void *blob, int node, uint32_t phandle)
> +{
> +       fdt32_t value = cpu_to_fdt32(phandle);
> +       int err;
> +
> +       err = fdt_setprop(blob, node, "linux,phandle", &value, sizeof(value));
> +       if (err < 0)
> +               return err;

Why set both properties?

> +
> +       err = fdt_setprop(blob, node, "phandle", &value, sizeof(value));
> +       if (err < 0)
> +               return err;
> +
> +       return 0;
> +}
> +
>  int fdtdec_setup(void)
>  {
>  #if CONFIG_IS_ENABLED(OF_CONTROL)
> --
> 2.20.1
>

Regards,
SImon

  reply	other threads:[~2019-03-10 21:51 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-08 20:11 [U-Boot] [PATCH 1/6] fdtdec: Add cpu_to_fdt_{addr,size}() macros Thierry Reding
2019-03-08 20:11 ` [U-Boot] [PATCH 2/6] fdtdec: Implement fdtdec_get_max_phandle() Thierry Reding
2019-03-10 21:51   ` Simon Glass
2019-03-11  9:27     ` Thierry Reding
2019-03-19  1:24       ` Simon Glass
2019-03-08 20:11 ` [U-Boot] [PATCH 3/6] fdtdec: Implement fdtdec_set_phandle() Thierry Reding
2019-03-10 21:51   ` Simon Glass [this message]
2019-03-11 10:04     ` Thierry Reding
2019-03-19  1:24       ` Simon Glass
2019-03-08 20:11 ` [U-Boot] [PATCH 4/6] fdtdec: Implement fdtdec_add_reserved_memory() Thierry Reding
2019-03-10 21:51   ` Simon Glass
2019-03-11 10:06     ` Thierry Reding
2019-03-19  1:24       ` Simon Glass
2019-03-08 20:11 ` [U-Boot] [PATCH 5/6] fdtdec: Implement carveout support functions Thierry Reding
2019-03-10 21:51   ` Simon Glass
2019-03-08 20:11 ` [U-Boot] [PATCH 6/6] p2371-2180: Add support for framebuffer carveouts Thierry Reding
2019-03-19  1:24   ` Simon Glass
2019-03-10 21:51 ` [U-Boot] [PATCH 1/6] fdtdec: Add cpu_to_fdt_{addr, size}() macros Simon Glass

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='CAPnjgZ3hzk6uLOgaEZSk=M=quAKSZ6FVOvfuyELSe8-0O_ndKA@mail.gmail.com' \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /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 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.