Re: [U-Boot] [PATCH 1/5] treewide: include libfdt_env.h before fdt.h

2013-01-20 Thread David Gibson
On Fri, Jan 18, 2013 at 06:59:46AM -0500, Gerald Van Baren wrote:
> On 01/17/2013 06:50 PM, David Gibson wrote:
> > On Thu, Jan 17, 2013 at 01:32:45PM -0500, Jerry Van Baren wrote:
> >> Hi Scott, Kim, David,
> 
> [snip]
> 
> >> libfdt_env.h is where Kim typedef'ed fdt16_t, fdt32_t, fdt64_t
> >> 
> >> I suspect the original intent was to have  be the file 
> >> that people #included.  For whatever reason, most includes are 
> >> (picking on fdt_ro.c arbitrarily): 51 #include "libfdt_env.h" 53
> >> #include  54 #include  Since libfdt.h #includes
> >> fdt.h and libfdt_env.h, lines 51 and 53 (above) are redundant.
> >> It sorts out OK in dtc because libfdt_env.h includes stdint.h and
> >> defines fdt*_t, but it messes me up in u-boot where (currently)
> >> libfdt_env.h does *not* include stdint.h...
> > 
> > Ok, so, the uboot libfdt_env.h should be fixed to define uintXX_t
> > and fdtXX_t (either by including stdint or my other means).  The
> > purpose of libfdt_env.h is to define the things that libfdt
> > requires, and those types are (now) such a requirement.
> 
> I like the move, but have not done it (yet).  I made a trial patch
> (see below) that uses libfdt.h as the interface and cleans out the
> (now redundant) other *fdt*.h includes.  If this is in the right
> direction, I'll move the fdtXX_t typedefs and formally submit it.
> 
> The test suite has one failure, but it fails with or without my changes.
> 
> $ make check | grep FAIL
> fdtget-runtest.sh 77 121 66 111 97 114 100 78 97 109 101 0 77 121 66
> 111 97 114 100 70 97 109 105 108 121 78 97 109 101 0
> label01.dts.fdtget.test.dtb / compatible: FAIL Results differ from
> expected
> *FAIL:1
> 
> ** TEST SUMMARY
> * Total testcases:1443
> *PASS:1442
> *FAIL:1
> *   Bad configuration:0
> * Strange test result:0
> **

Yeah, Jon and I are aware of that recently introduced bug.  I've had
other projects to attend to and haven't had a chance to fix it yet.
It's basically a testsuite bug though, so it should be harmless.

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/5] treewide: include libfdt_env.h before fdt.h

2013-01-18 Thread Gerald Van Baren
On 01/17/2013 06:50 PM, David Gibson wrote:
> On Thu, Jan 17, 2013 at 01:32:45PM -0500, Jerry Van Baren wrote:
>> Hi Scott, Kim, David,

[snip]

>> libfdt_env.h is where Kim typedef'ed fdt16_t, fdt32_t, fdt64_t
>> 
>> I suspect the original intent was to have  be the file 
>> that people #included.  For whatever reason, most includes are 
>> (picking on fdt_ro.c arbitrarily): 51 #include "libfdt_env.h" 53
>> #include  54 #include  Since libfdt.h #includes
>> fdt.h and libfdt_env.h, lines 51 and 53 (above) are redundant.
>> It sorts out OK in dtc because libfdt_env.h includes stdint.h and
>> defines fdt*_t, but it messes me up in u-boot where (currently)
>> libfdt_env.h does *not* include stdint.h...
> 
> Ok, so, the uboot libfdt_env.h should be fixed to define uintXX_t
> and fdtXX_t (either by including stdint or my other means).  The
> purpose of libfdt_env.h is to define the things that libfdt
> requires, and those types are (now) such a requirement.

I like the move, but have not done it (yet).  I made a trial patch
(see below) that uses libfdt.h as the interface and cleans out the
(now redundant) other *fdt*.h includes.  If this is in the right
direction, I'll move the fdtXX_t typedefs and formally submit it.

The test suite has one failure, but it fails with or without my changes.

$ make check | grep FAIL
fdtget-runtest.sh 77 121 66 111 97 114 100 78 97 109 101 0 77 121 66
111 97 114 100 70 97 109 105 108 121 78 97 109 101 0
label01.dts.fdtget.test.dtb / compatible:   FAIL Results differ from
expected
*FAIL:  1

** TEST SUMMARY
* Total testcases:  1443
*PASS:  1442
*FAIL:  1
*   Bad configuration:  0
* Strange test result:  0
**

gvb

>From 1fb0193670e012072d4a9e5ac480e3201aaf30fd Mon Sep 17 00:00:00 2001
From: Gerald Van Baren 
Date: Thu, 17 Jan 2013 21:14:01 -0500
Subject: [PATCH] Use the libfdt.h include as the interface definition

libfdt.h is the libfdt interface definition.  It includes fdt.h and
libfdt_env.h, so there is no reason to include those in the general code.

Signed-off-by: Gerald Van Baren 
---
 dtc.h|3 +--
 fdtdump.c|3 +--
 libfdt/fdt.c |3 ---
 libfdt/fdt_empty_tree.c  |3 ---
 libfdt/fdt_ro.c  |3 ---
 libfdt/fdt_rw.c  |3 ---
 libfdt/fdt_strerror.c|3 ---
 libfdt/fdt_sw.c  |3 ---
 libfdt/fdt_wip.c |3 ---
 libfdt/libfdt_internal.h |1 -
 10 files changed, 2 insertions(+), 26 deletions(-)

diff --git a/dtc.h b/dtc.h
index 3e42a07..a032645 100644
--- a/dtc.h
+++ b/dtc.h
@@ -32,8 +32,7 @@
 #include 
 #include 

-#include 
-#include 
+#include 

 #include "util.h"

diff --git a/fdtdump.c b/fdtdump.c
index b2c5b37..3919490 100644
--- a/fdtdump.c
+++ b/fdtdump.c
@@ -8,8 +8,7 @@
 #include 
 #include 

-#include 
-#include 
+#include 

 #include "util.h"

diff --git a/libfdt/fdt.c b/libfdt/fdt.c
index 57faba3..19b9043 100644
--- a/libfdt/fdt.c
+++ b/libfdt/fdt.c
@@ -48,11 +48,8 @@
  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-#include "libfdt_env.h"

-#include 
 #include 
-
 #include "libfdt_internal.h"

 int fdt_check_header(const void *fdt)
diff --git a/libfdt/fdt_empty_tree.c b/libfdt/fdt_empty_tree.c
index f72d13b..30c5525 100644
--- a/libfdt/fdt_empty_tree.c
+++ b/libfdt/fdt_empty_tree.c
@@ -48,11 +48,8 @@
  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-#include "libfdt_env.h"

-#include 
 #include 
-
 #include "libfdt_internal.h"

 int fdt_create_empty_tree(void *buf, int bufsize)
diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
index 42da2bd..53c61ed 100644
--- a/libfdt/fdt_ro.c
+++ b/libfdt/fdt_ro.c
@@ -48,11 +48,8 @@
  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-#include "libfdt_env.h"

-#include 
 #include 
-
 #include "libfdt_internal.h"

 static int _fdt_nodename_eq(const void *fdt, int offset,
diff --git a/libfdt/fdt_rw.c b/libfdt/fdt_rw.c
index fdba618..b6a8815 100644
--- a/libfdt/fdt_rw.c
+++ b/libfdt/fdt_rw.c
@@ -48,11 +48,8 @@
  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-#include "libfdt_env.h"

-#include 
 #include 
-
 #include "libfdt_internal.h"

 static int _fdt_blocks_misordered(const void *fdt,
diff --git a/libfdt/fdt_strerror.c b/libfdt/fdt_strerror.c
index e6c3cee..c55793c 100644
--- a/libfdt/fdt_strerror.c
+++ b/libfdt/fdt_strerror.c
@@ -48,11 +48,8 @@
  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-#include "libfdt_env.h"

-#include 
 #include 
-
 #include "libfdt_internal.h"

 struct fdt_errtabent {
diff --git a/libfdt/fdt_sw.c b/libfdt/

Re: [U-Boot] [PATCH 1/5] treewide: include libfdt_env.h before fdt.h

2013-01-18 Thread Jerry Van Baren
Hi Kim,

On 01/16/2013 06:59 PM, Kim Phillips wrote:
> and, if including libfdt.h which includes libfdt_env.h in
> the correct order, don't include fdt.h before libfdt.h.
> 
> this is needed to get the fdt type definitions set from
> the project environment before fdt.h uses them.
> 
> Signed-off-by: Kim Phillips 
> Cc: Jerry Van Baren 

Thanks, that was very helpful.  I applied the series to my personal
tree, will push when the dust settles.

I created a patch that uses just libfdt.h as the interface #include,
will publish when the dust settles on the dtc (device tree) list discussion.

Thanks,
gvb
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/5] treewide: include libfdt_env.h before fdt.h

2013-01-17 Thread David Gibson
On Thu, Jan 17, 2013 at 11:54:56AM -0600, Kim Phillips wrote:
> On Wed, 16 Jan 2013 18:36:03 -0600
> Scott Wood  wrote:
> 
> > On 01/16/2013 05:59:04 PM, Kim Phillips wrote:
> > > and, if including libfdt.h which includes libfdt_env.h in
> > > the correct order, don't include fdt.h before libfdt.h.
> > > 
> > > this is needed to get the fdt type definitions set from
> > > the project environment before fdt.h uses them.
> > > 
> > > Signed-off-by: Kim Phillips 
> > > Cc: Jerry Van Baren 
> > 
> > Maybe fdt.h should include libfdt_env.h?
> > 
> > Or just always use libfdt.h as the public header.
> 
> Was just following along the same lines as the dtc commits 38ad79d3
> "dtc/tests: don't include fdt.h prior to libfdt.h" and 20b866a7
> "dtc/fdtdump: include libfdt_env.h prior to fdt.h", acked by David
> G.  I don't know why some only include fdt.h.
> 
> devicetree-discuss/David: is there a prescribed way to go here?
> Change all fdt.h includers to just always include libfdt.h instead
> of libfdt_env.h prior to fdt.h?

Yeah, I think just including libfdt.h instead of fdt.h is the way to
go.  The distinction is that fdt.h contains only "passive"
declarations.  That is, defines and structure/type declarations but no
function prorotypes or other code.  In particular that means that it
is strictly about the FDT tree structure only, and not any of the
libfdt specific entry points.

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/5] treewide: include libfdt_env.h before fdt.h

2013-01-17 Thread David Gibson
On Thu, Jan 17, 2013 at 01:32:45PM -0500, Jerry Van Baren wrote:
> Hi Scott, Kim, David,
> 
> On 01/17/2013 12:54 PM, Kim Phillips wrote:
> >On Wed, 16 Jan 2013 18:36:03 -0600
> >Scott Wood  wrote:
> >
> >>On 01/16/2013 05:59:04 PM, Kim Phillips wrote:
> >>>and, if including libfdt.h which includes libfdt_env.h in
> >>>the correct order, don't include fdt.h before libfdt.h.
> >>>
> >>>this is needed to get the fdt type definitions set from
> >>>the project environment before fdt.h uses them.
> >>>
> >>>Signed-off-by: Kim Phillips 
> >>>Cc: Jerry Van Baren 
> >>
> >>Maybe fdt.h should include libfdt_env.h?
> >>
> >>Or just always use libfdt.h as the public header.
> >
> >Was just following along the same lines as the dtc commits 38ad79d3
> >"dtc/tests: don't include fdt.h prior to libfdt.h" and 20b866a7
> >"dtc/fdtdump: include libfdt_env.h prior to fdt.h", acked by David
> >G.  I don't know why some only include fdt.h.
> >
> >devicetree-discuss/David: is there a prescribed way to go here?
> >Change all fdt.h includers to just always include libfdt.h instead
> >of libfdt_env.h prior to fdt.h?
> 
> I started applying Kim's "sparse" patches to the u-boot source and
> ran into this issue pretty hard.
> 
> In u-boot, there is an added complexity that the "tools" (host-based
> u-boot support tools) support flattened device trees, but explicitly
> include the u-boot version of libfdt declarations so they don't fall
> out of sync if the host has a non-compatible libfdt version.  Having
> them out of sync would be a *horrible* situation to sort out -
> everything would build OK but nothing would work right, probably
> with no useful diagnostic information.  This originated in 2008, so
> life may be better nowadays.  Or maybe not.
> 
> I would be in favor of explicitly including all the *fdt* headers in
> the sources.  Alternately, Scott's suggestion of just including
> libfdt.h as the public header seems good, but I'm pretty sure it
> will mess me up with the explicit #including in the host-based
> "tools" build, leaving us with nasty work-arounds or a risk of hard
> to identify incompatible host vs. u-boot fdt versions.
> 
> Who Includes Who
> 
> fdt.h - no includes
> 
> fdt_support.h - (u-boot only file)
>   29 #include 
> 
> libfdt.h
>   54 #include 
>   55 #include 
> 
> libfdt_env.h
>  - u-boot version is minimal, uses pre-existing macros for byte swapping
>  - dtc version implements byte swapping, includes:
>4 #include 
>5 #include 
>6 #include 
> 
> libfdt_env.h is where Kim typedef'ed fdt16_t, fdt32_t, fdt64_t
> 
> I suspect the original intent was to have  be the file
> that people #included.  For whatever reason, most includes are
> (picking on fdt_ro.c arbitrarily):
>   51 #include "libfdt_env.h"
>   53 #include 
>   54 #include 
> Since libfdt.h #includes fdt.h and libfdt_env.h, lines 51 and 53
> (above) are redundant.  It sorts out OK in dtc because libfdt_env.h
> includes stdint.h and defines fdt*_t, but it messes me up in u-boot
> where (currently) libfdt_env.h does *not* include stdint.h...

Ok, so, the uboot libfdt_env.h should be fixed to define uintXX_t and
fdtXX_t (either by including stdint or my other means).  The purpose
of libfdt_env.h is to define the things that libfdt requires, and
those types are (now) such a requirement.

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/5] treewide: include libfdt_env.h before fdt.h

2013-01-17 Thread Jerry Van Baren

Hi Scott, Kim, David,

On 01/17/2013 12:54 PM, Kim Phillips wrote:

On Wed, 16 Jan 2013 18:36:03 -0600
Scott Wood  wrote:


On 01/16/2013 05:59:04 PM, Kim Phillips wrote:

and, if including libfdt.h which includes libfdt_env.h in
the correct order, don't include fdt.h before libfdt.h.

this is needed to get the fdt type definitions set from
the project environment before fdt.h uses them.

Signed-off-by: Kim Phillips 
Cc: Jerry Van Baren 


Maybe fdt.h should include libfdt_env.h?

Or just always use libfdt.h as the public header.


Was just following along the same lines as the dtc commits 38ad79d3
"dtc/tests: don't include fdt.h prior to libfdt.h" and 20b866a7
"dtc/fdtdump: include libfdt_env.h prior to fdt.h", acked by David
G.  I don't know why some only include fdt.h.

devicetree-discuss/David: is there a prescribed way to go here?
Change all fdt.h includers to just always include libfdt.h instead
of libfdt_env.h prior to fdt.h?


I started applying Kim's "sparse" patches to the u-boot source and ran 
into this issue pretty hard.


In u-boot, there is an added complexity that the "tools" (host-based 
u-boot support tools) support flattened device trees, but explicitly 
include the u-boot version of libfdt declarations so they don't fall out 
of sync if the host has a non-compatible libfdt version.  Having them 
out of sync would be a *horrible* situation to sort out - everything 
would build OK but nothing would work right, probably with no useful 
diagnostic information.  This originated in 2008, so life may be better 
nowadays.  Or maybe not.


I would be in favor of explicitly including all the *fdt* headers in the 
sources.  Alternately, Scott's suggestion of just including libfdt.h as 
the public header seems good, but I'm pretty sure it will mess me up 
with the explicit #including in the host-based "tools" build, leaving us 
with nasty work-arounds or a risk of hard to identify incompatible host 
vs. u-boot fdt versions.


Who Includes Who

fdt.h - no includes

fdt_support.h - (u-boot only file)
  29 #include 

libfdt.h
  54 #include 
  55 #include 

libfdt_env.h
 - u-boot version is minimal, uses pre-existing macros for byte swapping
 - dtc version implements byte swapping, includes:
   4 #include 
   5 #include 
   6 #include 

libfdt_env.h is where Kim typedef'ed fdt16_t, fdt32_t, fdt64_t

I suspect the original intent was to have  be the file that 
people #included.  For whatever reason, most includes are (picking on 
fdt_ro.c arbitrarily):

  51 #include "libfdt_env.h"
  53 #include 
  54 #include 
Since libfdt.h #includes fdt.h and libfdt_env.h, lines 51 and 53 (above) 
are redundant.  It sorts out OK in dtc because libfdt_env.h includes 
stdint.h and defines fdt*_t, but it messes me up in u-boot where 
(currently) libfdt_env.h does *not* include stdint.h... and then things 
get really wonky in the u-boot "tools" directory due to the need to use 
the u-boot version of the *fdt*.h headers, not random stuff installed on 
the computer.


HTH,
gvb

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


Re: [U-Boot] [PATCH 1/5] treewide: include libfdt_env.h before fdt.h

2013-01-17 Thread Kim Phillips
On Wed, 16 Jan 2013 18:36:03 -0600
Scott Wood  wrote:

> On 01/16/2013 05:59:04 PM, Kim Phillips wrote:
> > and, if including libfdt.h which includes libfdt_env.h in
> > the correct order, don't include fdt.h before libfdt.h.
> > 
> > this is needed to get the fdt type definitions set from
> > the project environment before fdt.h uses them.
> > 
> > Signed-off-by: Kim Phillips 
> > Cc: Jerry Van Baren 
> 
> Maybe fdt.h should include libfdt_env.h?
> 
> Or just always use libfdt.h as the public header.

Was just following along the same lines as the dtc commits 38ad79d3
"dtc/tests: don't include fdt.h prior to libfdt.h" and 20b866a7
"dtc/fdtdump: include libfdt_env.h prior to fdt.h", acked by David
G.  I don't know why some only include fdt.h.

devicetree-discuss/David: is there a prescribed way to go here?
Change all fdt.h includers to just always include libfdt.h instead
of libfdt_env.h prior to fdt.h?

Kim

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


Re: [U-Boot] [PATCH 1/5] treewide: include libfdt_env.h before fdt.h

2013-01-16 Thread Scott Wood

On 01/16/2013 05:59:04 PM, Kim Phillips wrote:

and, if including libfdt.h which includes libfdt_env.h in
the correct order, don't include fdt.h before libfdt.h.

this is needed to get the fdt type definitions set from
the project environment before fdt.h uses them.

Signed-off-by: Kim Phillips 
Cc: Jerry Van Baren 


Maybe fdt.h should include libfdt_env.h?

Or just always use libfdt.h as the public header.

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