Re: [U-Boot] [PATCH v3 04/13] fdtdec: Implement fdtdec_set_phandle()

2019-04-12 Thread sjg
Hi Thierry,

On Fri, 22 Mar 2019 at 16:34, Thierry Reding  wrote:
>
> On Fri, Mar 22, 2019 at 03:53:01PM +0800, Simon Glass wrote:
> > Hi Thierry,
> >
> > On Fri, 22 Mar 2019 at 02:10, Thierry Reding  
> > wrote:
> > >
> > > From: Thierry Reding 
> > >
> > > This function can be used to set a phandle for a given node.
> > >
> > > Signed-off-by: Thierry Reding 
> > > ---
> > > Changes in v2:
> > > - don't emit deprecated linux,phandle property
> > >
> > >  include/fdtdec.h | 11 +++
> > >  lib/fdtdec.c |  7 +++
> > >  2 files changed, 18 insertions(+)
> > >
Applied to u-boot-dm, thanks!
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 04/13] fdtdec: Implement fdtdec_set_phandle()

2019-03-22 Thread Simon Glass
Hi Thierry,

On Fri, 22 Mar 2019 at 16:34, Thierry Reding  wrote:
>
> On Fri, Mar 22, 2019 at 03:53:01PM +0800, Simon Glass wrote:
> > Hi Thierry,
> >
> > On Fri, 22 Mar 2019 at 02:10, Thierry Reding  
> > wrote:
> > >
> > > From: Thierry Reding 
> > >
> > > This function can be used to set a phandle for a given node.
> > >
> > > Signed-off-by: Thierry Reding 
> > > ---
> > > Changes in v2:
> > > - don't emit deprecated linux,phandle property
> > >
> > >  include/fdtdec.h | 11 +++
> > >  lib/fdtdec.c |  7 +++
> > >  2 files changed, 18 insertions(+)
> > >
> > > diff --git a/include/fdtdec.h b/include/fdtdec.h
> > > index a0ba57c6318b..55600026c488 100644
> > > --- a/include/fdtdec.h
> > > +++ b/include/fdtdec.h
> > > @@ -981,6 +981,17 @@ int fdtdec_setup_mem_size_base(void);
> > >   */
> > >  int fdtdec_setup_memory_banksize(void);
> > >
> > > +/**
> > > + * 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 09a7e133a539..00db90e3cdfd 100644
> > > --- a/lib/fdtdec.c
> > > +++ b/lib/fdtdec.c
> > > @@ -1243,6 +1243,13 @@ __weak void *board_fdt_blob_setup(void)
> > >  }
> > >  #endif
> > >
> > > +int fdtdec_set_phandle(void *blob, int node, uint32_t phandle)
> > > +{
> > > +   fdt32_t value = cpu_to_fdt32(phandle);
> > > +
> > > +   return fdt_setprop(blob, node, "phandle", , sizeof(value));
> >
> > Can we use fdt_setprop_u32() instead?
>
> Yeah, we could. I'm not sure if after that optimization it's even worth
> keeping the extra wrapper. There may be some benefit in having a
> separate name for this because it's a somewhat special purpose. Maybe I
> should make it a static inline function instead?

I think it is worth it. But perhaps a static inline makes sense, up to you.

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 04/13] fdtdec: Implement fdtdec_set_phandle()

2019-03-22 Thread Thierry Reding
On Fri, Mar 22, 2019 at 03:53:01PM +0800, Simon Glass wrote:
> Hi Thierry,
> 
> On Fri, 22 Mar 2019 at 02:10, Thierry Reding  wrote:
> >
> > From: Thierry Reding 
> >
> > This function can be used to set a phandle for a given node.
> >
> > Signed-off-by: Thierry Reding 
> > ---
> > Changes in v2:
> > - don't emit deprecated linux,phandle property
> >
> >  include/fdtdec.h | 11 +++
> >  lib/fdtdec.c |  7 +++
> >  2 files changed, 18 insertions(+)
> >
> > diff --git a/include/fdtdec.h b/include/fdtdec.h
> > index a0ba57c6318b..55600026c488 100644
> > --- a/include/fdtdec.h
> > +++ b/include/fdtdec.h
> > @@ -981,6 +981,17 @@ int fdtdec_setup_mem_size_base(void);
> >   */
> >  int fdtdec_setup_memory_banksize(void);
> >
> > +/**
> > + * 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 09a7e133a539..00db90e3cdfd 100644
> > --- a/lib/fdtdec.c
> > +++ b/lib/fdtdec.c
> > @@ -1243,6 +1243,13 @@ __weak void *board_fdt_blob_setup(void)
> >  }
> >  #endif
> >
> > +int fdtdec_set_phandle(void *blob, int node, uint32_t phandle)
> > +{
> > +   fdt32_t value = cpu_to_fdt32(phandle);
> > +
> > +   return fdt_setprop(blob, node, "phandle", , sizeof(value));
> 
> Can we use fdt_setprop_u32() instead?

Yeah, we could. I'm not sure if after that optimization it's even worth
keeping the extra wrapper. There may be some benefit in having a
separate name for this because it's a somewhat special purpose. Maybe I
should make it a static inline function instead?

Thierry

> 
> > +}
> > +
> >  int fdtdec_setup(void)
> >  {
> >  #if CONFIG_IS_ENABLED(OF_CONTROL)
> > --
> > 2.21.0
> >
> 
> Regards,
> Simon


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 04/13] fdtdec: Implement fdtdec_set_phandle()

2019-03-22 Thread Simon Glass
Hi Thierry,

On Fri, 22 Mar 2019 at 02:10, Thierry Reding  wrote:
>
> From: Thierry Reding 
>
> This function can be used to set a phandle for a given node.
>
> Signed-off-by: Thierry Reding 
> ---
> Changes in v2:
> - don't emit deprecated linux,phandle property
>
>  include/fdtdec.h | 11 +++
>  lib/fdtdec.c |  7 +++
>  2 files changed, 18 insertions(+)
>
> diff --git a/include/fdtdec.h b/include/fdtdec.h
> index a0ba57c6318b..55600026c488 100644
> --- a/include/fdtdec.h
> +++ b/include/fdtdec.h
> @@ -981,6 +981,17 @@ int fdtdec_setup_mem_size_base(void);
>   */
>  int fdtdec_setup_memory_banksize(void);
>
> +/**
> + * 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 09a7e133a539..00db90e3cdfd 100644
> --- a/lib/fdtdec.c
> +++ b/lib/fdtdec.c
> @@ -1243,6 +1243,13 @@ __weak void *board_fdt_blob_setup(void)
>  }
>  #endif
>
> +int fdtdec_set_phandle(void *blob, int node, uint32_t phandle)
> +{
> +   fdt32_t value = cpu_to_fdt32(phandle);
> +
> +   return fdt_setprop(blob, node, "phandle", , sizeof(value));

Can we use fdt_setprop_u32() instead?

> +}
> +
>  int fdtdec_setup(void)
>  {
>  #if CONFIG_IS_ENABLED(OF_CONTROL)
> --
> 2.21.0
>

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 04/13] fdtdec: Implement fdtdec_set_phandle()

2019-03-21 Thread Thierry Reding
From: Thierry Reding 

This function can be used to set a phandle for a given node.

Signed-off-by: Thierry Reding 
---
Changes in v2:
- don't emit deprecated linux,phandle property

 include/fdtdec.h | 11 +++
 lib/fdtdec.c |  7 +++
 2 files changed, 18 insertions(+)

diff --git a/include/fdtdec.h b/include/fdtdec.h
index a0ba57c6318b..55600026c488 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -981,6 +981,17 @@ int fdtdec_setup_mem_size_base(void);
  */
 int fdtdec_setup_memory_banksize(void);
 
+/**
+ * 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 09a7e133a539..00db90e3cdfd 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1243,6 +1243,13 @@ __weak void *board_fdt_blob_setup(void)
 }
 #endif
 
+int fdtdec_set_phandle(void *blob, int node, uint32_t phandle)
+{
+   fdt32_t value = cpu_to_fdt32(phandle);
+
+   return fdt_setprop(blob, node, "phandle", , sizeof(value));
+}
+
 int fdtdec_setup(void)
 {
 #if CONFIG_IS_ENABLED(OF_CONTROL)
-- 
2.21.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot