mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/1] of: add do_fixup_by_compatible with u32 and string version
@ 2013-02-16 18:18 Jean-Christophe PLAGNIOL-VILLARD
  2013-02-18  8:59 ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-16 18:18 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 common/oftree.c |   27 +++++++++++++++++++++++++++
 include/of.h    |    6 ++++++
 2 files changed, 33 insertions(+)

diff --git a/common/oftree.c b/common/oftree.c
index 6b20cdb..82e5ddd 100644
--- a/common/oftree.c
+++ b/common/oftree.c
@@ -229,6 +229,33 @@ void do_fixup_by_path_u32(struct fdt_header *fdt, const char *path,
 	do_fixup_by_path(fdt, path, prop, &val, sizeof(val), create);
 }
 
+void do_fixup_by_compatible(struct fdt_header *fdt, const char *compatible,
+			const char *prop, const void *val, int len, int create)
+{
+	int off = -1;
+
+	off = fdt_node_offset_by_compatible(fdt, -1, compatible);
+	while (off != -FDT_ERR_NOTFOUND) {
+		if (create || (fdt_get_property(fdt, off, prop, 0) != NULL))
+			fdt_setprop(fdt, off, prop, val, len);
+		off = fdt_node_offset_by_compatible(fdt, off, compatible);
+	}
+}
+
+void do_fixup_by_compatible_u32(struct fdt_header *fdt, const char *compatible,
+				const char *prop, u32 val, int create)
+{
+	val = cpu_to_fdt32(val);
+	do_fixup_by_compatible(fdt, compatible, prop, &val, 4, create);
+}
+
+void do_fixup_by_compatible_string(struct fdt_header *fdt, const char *compatible,
+				const char *prop, const char *val, int create)
+{
+	do_fixup_by_compatible(fdt, compatible, prop, val, strlen(val) + 1,
+				create);
+}
+
 int fdt_get_path_or_create(struct fdt_header *fdt, const char *path)
 {
 	int nodeoffset;
diff --git a/include/of.h b/include/of.h
index 4dc5b6c..95d9702 100644
--- a/include/of.h
+++ b/include/of.h
@@ -17,6 +17,12 @@ void do_fixup_by_path(struct fdt_header *fdt, const char *path, const char *prop
 		      const void *val, int len, int create);
 void do_fixup_by_path_u32(struct fdt_header *fdt, const char *path, const char *prop,
 			  u32 val, int create);
+void do_fixup_by_compatible(struct fdt_header *fdt, const char *compatible,
+			const char *prop, const void *val, int len, int create);
+void do_fixup_by_compatible_u32(struct fdt_header *fdt, const char *compatible,
+				const char *prop, u32 val, int create);
+void do_fixup_by_compatible_string(struct fdt_header *fdt, const char *compatible,
+				const char *prop, const char *val, int create);
 int fdt_get_path_or_create(struct fdt_header *fdt, const char *path);
 #ifdef CONFIG_FDT
 int fdt_initrd(void *fdt, ulong initrd_start, ulong initrd_end, int force);
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] of: add do_fixup_by_compatible with u32 and string version
  2013-02-16 18:18 [PATCH 1/1] of: add do_fixup_by_compatible with u32 and string version Jean-Christophe PLAGNIOL-VILLARD
@ 2013-02-18  8:59 ` Sascha Hauer
  2013-02-18 17:44   ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2013-02-18  8:59 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Sat, Feb 16, 2013 at 07:18:39PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  common/oftree.c |   27 +++++++++++++++++++++++++++
>  include/of.h    |    6 ++++++
>  2 files changed, 33 insertions(+)
> 
> diff --git a/common/oftree.c b/common/oftree.c
> index 6b20cdb..82e5ddd 100644
> --- a/common/oftree.c
> +++ b/common/oftree.c
> @@ -229,6 +229,33 @@ void do_fixup_by_path_u32(struct fdt_header *fdt, const char *path,
>  	do_fixup_by_path(fdt, path, prop, &val, sizeof(val), create);
>  }
>  
> +void do_fixup_by_compatible(struct fdt_header *fdt, const char *compatible,
> +			const char *prop, const void *val, int len, int create)
> +{
> +	int off = -1;
> +
> +	off = fdt_node_offset_by_compatible(fdt, -1, compatible);
> +	while (off != -FDT_ERR_NOTFOUND) {
> +		if (create || (fdt_get_property(fdt, off, prop, 0) != NULL))
> +			fdt_setprop(fdt, off, prop, val, len);
> +		off = fdt_node_offset_by_compatible(fdt, off, compatible);
> +	}
> +}

IMO we shouldn't increase the dependency on libfdt. The fdt format is a
nice storage format, but it sucks for modifying the tree.
I created some patches to get rid of libfdt entirely yesterday. They are
not complete yet, but removing libfdt has some nice effects:

- Smaller binaries
- No more parallel universes of fdt and internal trees. This currently makes the
  devicetree code messy
- I trimmed down the overhead of unflattening/flattening significantly.
  It still adds some overhead to do it, but manipulating the tree is a
  factor of 50 faster which means once you have multiple manipulations
  of the tree it reduces the overhead to a net win.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] of: add do_fixup_by_compatible with u32 and string version
  2013-02-18  8:59 ` Sascha Hauer
@ 2013-02-18 17:44   ` Jean-Christophe PLAGNIOL-VILLARD
  2013-03-04  7:56     ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-02-18 17:44 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 09:59 Mon 18 Feb     , Sascha Hauer wrote:
> On Sat, Feb 16, 2013 at 07:18:39PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > ---
> >  common/oftree.c |   27 +++++++++++++++++++++++++++
> >  include/of.h    |    6 ++++++
> >  2 files changed, 33 insertions(+)
> > 
> > diff --git a/common/oftree.c b/common/oftree.c
> > index 6b20cdb..82e5ddd 100644
> > --- a/common/oftree.c
> > +++ b/common/oftree.c
> > @@ -229,6 +229,33 @@ void do_fixup_by_path_u32(struct fdt_header *fdt, const char *path,
> >  	do_fixup_by_path(fdt, path, prop, &val, sizeof(val), create);
> >  }
> >  
> > +void do_fixup_by_compatible(struct fdt_header *fdt, const char *compatible,
> > +			const char *prop, const void *val, int len, int create)
> > +{
> > +	int off = -1;
> > +
> > +	off = fdt_node_offset_by_compatible(fdt, -1, compatible);
> > +	while (off != -FDT_ERR_NOTFOUND) {
> > +		if (create || (fdt_get_property(fdt, off, prop, 0) != NULL))
> > +			fdt_setprop(fdt, off, prop, val, len);
> > +		off = fdt_node_offset_by_compatible(fdt, off, compatible);
> > +	}
> > +}
> 
> IMO we shouldn't increase the dependency on libfdt. The fdt format is a
> nice storage format, but it sucks for modifying the tree.
> I created some patches to get rid of libfdt entirely yesterday. They are
> not complete yet, but removing libfdt has some nice effects:
> 
> - Smaller binaries
> - No more parallel universes of fdt and internal trees. This currently makes the
>   devicetree code messy
> - I trimmed down the overhead of unflattening/flattening significantly.
>   It still adds some overhead to do it, but manipulating the tree is a
>   factor of 50 faster which means once you have multiple manipulations
>   of the tree it reduces the overhead to a net win.
ok will this be availlable for next release ok ohterwise can we have this
patch first so we can have the fixuo support for highbank

Best Regards,
J.
> 
> Sascha
> 
> -- 
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] of: add do_fixup_by_compatible with u32 and string version
  2013-02-18 17:44   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2013-03-04  7:56     ` Sascha Hauer
  0 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2013-03-04  7:56 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Mon, Feb 18, 2013 at 06:44:33PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 09:59 Mon 18 Feb     , Sascha Hauer wrote:
> > On Sat, Feb 16, 2013 at 07:18:39PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > > ---
> > >  common/oftree.c |   27 +++++++++++++++++++++++++++
> > >  include/of.h    |    6 ++++++
> > >  2 files changed, 33 insertions(+)
> > > 
> > > diff --git a/common/oftree.c b/common/oftree.c
> > > index 6b20cdb..82e5ddd 100644
> > > --- a/common/oftree.c
> > > +++ b/common/oftree.c
> > > @@ -229,6 +229,33 @@ void do_fixup_by_path_u32(struct fdt_header *fdt, const char *path,
> > >  	do_fixup_by_path(fdt, path, prop, &val, sizeof(val), create);
> > >  }
> > >  
> > > +void do_fixup_by_compatible(struct fdt_header *fdt, const char *compatible,
> > > +			const char *prop, const void *val, int len, int create)
> > > +{
> > > +	int off = -1;
> > > +
> > > +	off = fdt_node_offset_by_compatible(fdt, -1, compatible);
> > > +	while (off != -FDT_ERR_NOTFOUND) {
> > > +		if (create || (fdt_get_property(fdt, off, prop, 0) != NULL))
> > > +			fdt_setprop(fdt, off, prop, val, len);
> > > +		off = fdt_node_offset_by_compatible(fdt, off, compatible);
> > > +	}
> > > +}
> > 
> > IMO we shouldn't increase the dependency on libfdt. The fdt format is a
> > nice storage format, but it sucks for modifying the tree.
> > I created some patches to get rid of libfdt entirely yesterday. They are
> > not complete yet, but removing libfdt has some nice effects:
> > 
> > - Smaller binaries
> > - No more parallel universes of fdt and internal trees. This currently makes the
> >   devicetree code messy
> > - I trimmed down the overhead of unflattening/flattening significantly.
> >   It still adds some overhead to do it, but manipulating the tree is a
> >   factor of 50 faster which means once you have multiple manipulations
> >   of the tree it reduces the overhead to a net win.
> ok will this be availlable for next release ok ohterwise can we have this
> patch first so we can have the fixuo support for highbank

I applied this one and the highbank patches using it. I have to rework
My devicetree series anyway, so it will be too late to merge this to
-next before the march release.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-03-04  7:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-16 18:18 [PATCH 1/1] of: add do_fixup_by_compatible with u32 and string version Jean-Christophe PLAGNIOL-VILLARD
2013-02-18  8:59 ` Sascha Hauer
2013-02-18 17:44   ` Jean-Christophe PLAGNIOL-VILLARD
2013-03-04  7:56     ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox