diff mbox

[U-Boot,v3,09/12] libfdt: Add fdt_getprop_namelen_w

Message ID 20160624142757.32735-10-maxime.ripard@free-electrons.com
State Accepted
Commit 2b941bf96dd66a5730f1dcbcb635e28930aa58fa
Delegated to: Pantelis Antoniou
Headers show

Commit Message

Maxime Ripard June 24, 2016, 2:27 p.m. UTC
Add a function to retrieve a writeable property only by the first
characters of its name.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 include/libfdt.h | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Simon Glass June 26, 2016, 2:53 a.m. UTC | #1
Hi Maxime,

On 24 June 2016 at 08:27, Maxime Ripard
<maxime.ripard@free-electrons.com> wrote:
> Add a function to retrieve a writeable property only by the first
> characters of its name.
>
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
>  include/libfdt.h | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/include/libfdt.h b/include/libfdt.h
> index dbe8a0efca87..b8758de3ae54 100644
> --- a/include/libfdt.h
> +++ b/include/libfdt.h
> @@ -619,6 +619,13 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset,
>   */
>  const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
>                                 const char *name, int namelen, int *lenp);
> +static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset,
> +                                         const char *name, int namelen,
> +                                         int *lenp)
> +{
> +       return (void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name,
> +                                                     namelen, lenp);

What are the casts for?

> +}
>
>  /**
>   * fdt_getprop - retrieve the value of a given property
> --
> 2.9.0

Regards,
Simon
Maxime Ripard June 26, 2016, 8:11 a.m. UTC | #2
Hi Simon,

On Sat, Jun 25, 2016 at 08:53:55PM -0600, Simon Glass wrote:
> Hi Maxime,
> 
> On 24 June 2016 at 08:27, Maxime Ripard
> <maxime.ripard@free-electrons.com> wrote:
> > Add a function to retrieve a writeable property only by the first
> > characters of its name.
> >
> > Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> > ---
> >  include/libfdt.h | 7 +++++++
> >  1 file changed, 7 insertions(+)
> >
> > diff --git a/include/libfdt.h b/include/libfdt.h
> > index dbe8a0efca87..b8758de3ae54 100644
> > --- a/include/libfdt.h
> > +++ b/include/libfdt.h
> > @@ -619,6 +619,13 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset,
> >   */
> >  const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
> >                                 const char *name, int namelen, int *lenp);
> > +static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset,
> > +                                         const char *name, int namelen,
> > +                                         int *lenp)
> > +{
> > +       return (void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name,
> > +                                                     namelen, lenp);
> 
> What are the casts for?

This is modelled after the already existing fdt_getprop_w.

The casts just remove the const qualifier in fdt_getprop return value
so that you can modify it.

Maxime
David Gibson June 26, 2016, 3:49 p.m. UTC | #3
On Fri, Jun 24, 2016 at 04:27:54PM +0200, Maxime Ripard wrote:
> Add a function to retrieve a writeable property only by the first
> characters of its name.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
>  include/libfdt.h | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/include/libfdt.h b/include/libfdt.h
> index dbe8a0efca87..b8758de3ae54 100644
> --- a/include/libfdt.h
> +++ b/include/libfdt.h
> @@ -619,6 +619,13 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset,
>   */
>  const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
>  				const char *name, int namelen, int *lenp);
> +static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset,
> +					  const char *name, int namelen,
> +					  int *lenp)
> +{
> +	return (void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name,
> +						      namelen, lenp);
> +}

I believe you used this in your new setprop_inpace implementation.  So
the series needs to be re-ordered to avoid breaking bisection.
Maxime Ripard June 27, 2016, 7:29 a.m. UTC | #4
On Mon, Jun 27, 2016 at 01:49:29AM +1000, David Gibson wrote:
> On Fri, Jun 24, 2016 at 04:27:54PM +0200, Maxime Ripard wrote:
> > Add a function to retrieve a writeable property only by the first
> > characters of its name.
> > 
> > Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> > ---
> >  include/libfdt.h | 7 +++++++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/include/libfdt.h b/include/libfdt.h
> > index dbe8a0efca87..b8758de3ae54 100644
> > --- a/include/libfdt.h
> > +++ b/include/libfdt.h
> > @@ -619,6 +619,13 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset,
> >   */
> >  const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
> >  				const char *name, int namelen, int *lenp);
> > +static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset,
> > +					  const char *name, int namelen,
> > +					  int *lenp)
> > +{
> > +	return (void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name,
> > +						      namelen, lenp);
> > +}
> 
> I believe you used this in your new setprop_inpace implementation.  So
> the series needs to be re-ordered to avoid breaking bisection.

You're right, sorry for that.

Thanks!
Maxime
diff mbox

Patch

diff --git a/include/libfdt.h b/include/libfdt.h
index dbe8a0efca87..b8758de3ae54 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -619,6 +619,13 @@  const void *fdt_getprop_by_offset(const void *fdt, int offset,
  */
 const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
 				const char *name, int namelen, int *lenp);
+static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset,
+					  const char *name, int namelen,
+					  int *lenp)
+{
+	return (void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name,
+						      namelen, lenp);
+}
 
 /**
  * fdt_getprop - retrieve the value of a given property