libfdt: add fdt type definitions in libfdt_env.h
Subsystems (2)
PATCH 1/3 libfdt: add fdt type definitions in libfdt_env.h
in preparation for the forthcoming dtc update which adds fdt specific
types: fdt{16,32,64}_t.
--- arch/arm/boot/compressed/libfdt_env.h | 4 ++++ include/linux/libfdt_env.h | 6 ++++++ 2 files changed, 10 insertions(+)
arch/arm/boot/compressed/libfdt_env.h +4 -0
@@ -5,6 +5,10 @@#include <linux/string.h> #include <asm/byteorder.h> +typedef __be16 fdt16_t ; +typedef __be32 fdt32_t ; +typedef __be64 fdt64_t ; +#define fdt16_to_cpu (x) be16_to_cpu(x)#define cpu_to_fdt16 (x) cpu_to_be16(x)#define fdt32_to_cpu (x) be32_to_cpu(x)
include/linux/libfdt_env.h +6 -0
@@ -5,6 +5,12 @@#include <asm/byteorder.h> +typedef __be16 fdt16_t ; +typedef __be32 fdt32_t ; +typedef __be64 fdt64_t ; + +#define fdt16_to_cpu (x) be16_to_cpu(x) +#define cpu_to_fdt16 (x) cpu_to_be16(x)#define fdt32_to_cpu (x) be32_to_cpu(x)#define cpu_to_fdt32 (x) cpu_to_be32(x)#define fdt64_to_cpu (x) be64_to_cpu(x)
Signature · 1 line
1.8.1.4
PATCH 2/3 dtc: import latest upstream dtc
This updates scripts/dtc to upstream dtc commit 27cdc1b "Added license header to dtc/libfdt/fdt.h and libfdt_env.h" from git://git.jdl.com/software/dtc.git.
--- scripts/dtc/dtc.c | 3 -- scripts/dtc/fdtdump.c | 29 +---------- scripts/dtc/libfdt/fdt.c | 2 +- scripts/dtc/libfdt/fdt.h | 93 +++++++++++++++++++++++++++-------- scripts/dtc/libfdt/fdt_ro.c | 7 ++- scripts/dtc/libfdt/fdt_rw.c | 4 +- scripts/dtc/libfdt/fdt_sw.c | 4 +- scripts/dtc/libfdt/fdt_wip.c | 2 +- scripts/dtc/libfdt/libfdt.h | 48 ++++++++++++------- scripts/dtc/libfdt/libfdt_env.h | 104 +++++++++++++++++++++++++++++++++++----- scripts/dtc/srcpos.c | 6 +-- scripts/dtc/util.c | 57 +++++++++++++++++++--- scripts/dtc/util.h | 22 +++++++-- 13 files changed, 279 insertions(+), 102 deletions(-)
scripts/dtc/dtc.c +0 -3
@@ -201,9 +201,6 @@ int main(int argc, char *argv[])if (minsize && padsize)die ("Can't set both -p and -S\n" ); -if (minsize) -fprintf (stderr,"DTC: Use of \"-S\" is deprecated; it will be removed soon, use \"-p\" instead\n" ); -if (depname) { depfile =fopen (depname,"w" );if (!depfile)
scripts/dtc/fdtdump.c +2 -27
@@ -8,8 +8,8 @@#include <string.h> #include <ctype.h> -#include <fdt.h> #include <libfdt_env.h> +#include <fdt.h> #include "util.h"
@@ -17,31 +17,6 @@#define PALIGN (p, a) ((void *)(ALIGN((unsigned long)(p), (a))))#define GET_CELL (p) (p += 4, *((const uint32_t *)(p-4))) -static void print_data (const char *data,int len) -{ -int i; -const char *p = data; - -/* no data, don't print */ -if (len ==0 ) -return ; - -if (util_is_printable_string (data, len)) { -printf (" = \"%s\"" , (const char *)data); - }else if ((len %4 ) ==0 ) { -printf (" = <" ); -for (i =0 ; i < len; i +=4 ) -printf ("0x%08x%s" ,fdt32_to_cpu (GET_CELL (p)), - i < (len -4 ) ?" " :"" ); -printf (">" ); - }else { -printf (" = [" ); -for (i =0 ; i < len; i++) -printf ("%02x%s" , *p++, i < len -1 ?" " :"" ); -printf ("]" ); - } -} -static void dump_blob (void *blob) {struct fdt_header *bph = blob;
@@ -137,7 +112,7 @@ static void dump_blob(void *blob) p =PALIGN (p + sz,4 );printf ("%*s%s" , depth * shift,"" , s); -print_data (t, sz); +utilfdt_print_data (t, sz);printf (";\n" ); } }
scripts/dtc/libfdt/fdt.c +1 -1
@@ -92,7 +92,7 @@ const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len)uint32_t fdt_next_tag (const void *fdt,int startoffset,int *nextoffset) { -const uint32_t *tagp, *lenp; +const fdt32_t *tagp, *lenp;uint32_t tag;int offset = startoffset;const char *p;
scripts/dtc/libfdt/fdt.h +72 -21
130 lines not on this page · raw message
scripts/dtc/libfdt/fdt_ro.c +3 -4
@@ -322,7 +322,7 @@ const void *fdt_getprop(const void *fdt, int nodeoffset,uint32_t fdt_get_phandle (const void *fdt,int nodeoffset) { -const uint32_t *php; +const fdt32_t *php;int len;/* FIXME: This is a bit sub-optimal, since we potentially scan
@@ -515,8 +515,7 @@ int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle)return offset;/* error from fdt_next_node() */ } -static int _fdt_stringlist_contains (const char *strlist,int listlen, -const char *str) +int fdt_stringlist_contains (const char *strlist,int listlen,const char *str) {int len =strlen (str);const char *p;
@@ -542,7 +541,7 @@ int fdt_node_check_compatible(const void *fdt, int nodeoffset, prop =fdt_getprop (fdt, nodeoffset,"compatible" , &len);if (!prop)return len; -if (_fdt_stringlist_contains (prop, len, compatible)) +if (fdt_stringlist_contains (prop, len, compatible))return 0 ;else return 1 ;
scripts/dtc/libfdt/fdt_rw.c +2 -2
@@ -339,7 +339,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,int nodelen;int err;uint32_t tag; -uint32_t *endtag; +fdt32_t *endtag;FDT_RW_CHECK_HEADER (fdt);
@@ -366,7 +366,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset, nh->tag =cpu_to_fdt32 (FDT_BEGIN_NODE );memset (nh->name,0 ,FDT_TAGALIGN (namelen+1 ));memcpy (nh->name, name, namelen); - endtag = (uint32_t *)((char *)nh + nodelen -FDT_TAGSIZE ); + endtag = (fdt32_t *)((char *)nh + nodelen -FDT_TAGSIZE ); *endtag =cpu_to_fdt32 (FDT_END_NODE );return offset;
scripts/dtc/libfdt/fdt_sw.c +2 -2
@@ -153,7 +153,7 @@ int fdt_begin_node(void *fdt, const char *name)int fdt_end_node (void *fdt) { -uint32_t *en; +fdt32_t *en;FDT_SW_CHECK_HEADER (fdt);
@@ -213,7 +213,7 @@ int fdt_property(void *fdt, const char *name, const void *val, int len)int fdt_finish (void *fdt) {char *p = (char *)fdt; -uint32_t *end; +fdt32_t *end;int oldstroffset, newstroffset;uint32_t tag;int offset, nextoffset;
scripts/dtc/libfdt/fdt_wip.c +1 -1
@@ -74,7 +74,7 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,static void _fdt_nop_region (void *start,int len) { -uint32_t *p; +fdt32_t *p;for (p = start; (char *)p < ((char *)start + len); p++) *p =cpu_to_fdt32 (FDT_NOP );
scripts/dtc/libfdt/libfdt.h +31 -17
105 lines not on this page · raw message
scripts/dtc/libfdt/libfdt_env.h +93 -11
122 lines not on this page · raw message
scripts/dtc/srcpos.c +3 -3
@@ -297,9 +297,9 @@ srcpos_verror(struct srcpos *pos, char const *fmt, va_list va) srcstr =srcpos_string (pos); -fprintf (stdout,"Error: %s " , srcstr); -vfprintf (stdout, fmt, va); -fprintf (stdout,"\n" ); +fprintf (stderr,"Error: %s " , srcstr); +vfprintf (stderr, fmt, va); +fprintf (stderr,"\n" ); }void
scripts/dtc/util.c +50 -7
73 lines not on this page · raw message
scripts/dtc/util.h +19 -3
@@ -57,12 +57,14 @@ extern char *xstrdup(const char *s);extern char *join_path (const char *path,const char *name);/** -* Check a string of a given length to see if it is all printable and -* has a valid terminator. +* Check a property of a given length to see if it is all printable and +* has a valid terminator. The property can contain either a single string, +* or multiple strings each of non-zero length. * * @param data The string to check * @param len The string length including terminator -* @return 1 if a valid printable string, 0 if not */ +* @return 1 if a valid printable string, 0 if not +*/ int util_is_printable_string (const void *data,int len);/*
@@ -150,4 +152,18 @@ int utilfdt_decode_type(const char *fmt, int *type, int *size);"\tOptional modifier prefix:\n" \"\t\thh or b=byte, h=2 byte, l=4 byte (default)\n" ; +/** +* Print property data in a readable format to stdout +* +* Properties that look like strings will be printed as strings. Otherwise +* the data will be displayed either as cells (if len is a multiple of 4 +* bytes) or bytes. +* +* If len is 0 then this function does nothing. +* +* @param data Pointers to property data +* @param len Length of property data +*/ +void utilfdt_print_data (const char *data,int len); +#endif /* _UTIL_H */
Signature · 1 line
1.8.1.4
Re: [PATCH 2/3] dtc: import latest upstream dtc
Quoted 1 line · Kim Phillips
This updates
scripts/dtcto upstream dtc commit 27cdc1b
There's an upstream for dts?
Quoted 2 lines
"Added license header to
dtc/libfdt/fdt.handlibfdt_env.h" fromgit://git.jdl.com/software/dtc.git.
That git repository has a Documentation directory with for example "dts-format.txt" in it. My current linux git repository does not contain a file called dts-format.txt.
Ummm... huh?
Rob
Re: [PATCH 2/3] dtc: import latest upstream dtc
Quoted 4 lines · On Tue, 26 Feb 2013 21:08:06 -0600 Rob Landley <[email protected]> wrote:
Quoted 1 line · Kim Phillips
This updates
scripts/dtcto upstream dtc commit 27cdc1bThere's an upstream for dts?
dtc - the device tree compiler, yes.
Quoted 6 lines
Quoted 2 lines
"Added license header to
dtc/libfdt/fdt.handlibfdt_env.h" fromgit://git.jdl.com/software/dtc.git.That git repository has a Documentation directory with for example "dts-format.txt" in it. My current linux git repository does not contain a file called dts-format.txt.
this patch isn't attempting to update dts-format.txt, or any other file that exists in the upstream dtc project that isn't present - and used - in the kernel. The purpose of this patch is to update libfdt, which has in-kernel users.
Kim
PATCH 3/3 ARM: zImage: sparse fixes
In reply to Kim Phillipsarch/arm/boot/compressed/atags_to_fdt.c:107:34: warning: cast to restricted __be32 arch/arm/boot/compressed/atags_to_fdt.c:107:34: warning: cast to restricted __be32 arch/arm/boot/compressed/atags_to_fdt.c:107:34: warning: cast to restricted __be32 arch/arm/boot/compressed/atags_to_fdt.c:107:34: warning: cast to restricted __be32 arch/arm/boot/compressed/atags_to_fdt.c:107:34: warning: cast to restricted __be32 arch/arm/boot/compressed/atags_to_fdt.c:107:34: warning: cast to restricted __be32 arch/arm/boot/compressed/atags_to_fdt.c:140:54: warning: incorrect type in assignment (different base types)arch/arm/boot/compressed/atags_to_fdt.c:140:54: expected unsigned int [unsigned] <noident>arch/arm/boot/compressed/atags_to_fdt.c:140:54: got restricted __be32 [usertype] <noident>arch/arm/boot/compressed/atags_to_fdt.c:141:54: warning: incorrect type in assignment (different base types)arch/arm/boot/compressed/atags_to_fdt.c:141:54: expected unsigned int [unsigned] <noident>arch/arm/boot/compressed/atags_to_fdt.c:141:54: got restricted __be32 [usertype] <noident>
--- arch/arm/boot/compressed/atags_to_fdt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/boot/compressed/atags_to_fdt.c +3 -3
@@ -16,7 +16,7 @@ static int node_offset(void *fdt, const char *node_path) }static int setprop (void *fdt,const char *node_path,const char *property, -uint32_t *val_array,int size) +fdt32_t *val_array,int size) {int offset =node_offset (fdt, node_path);if (offset <0 )
@@ -95,7 +95,7 @@ static void merge_fdt_bootargs(void *fdt, const char *fdt_cmdline)int atags_to_fdt (void *atag_list,void *fdt,int total_space) {struct tag *atag = atag_list; -uint32_t mem_reg_property[2 *NR_BANKS ]; +fdt32_t mem_reg_property[2 *NR_BANKS ];int memcount =0 ;int ret;
@@ -104,7 +104,7 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space)return 1 ;/* if we get a DTB here we're done already */ -if (*(u32 *)atag_list ==fdt32_to_cpu (FDT_MAGIC )) +if (*(fdt32_t *)atag_list ==cpu_to_fdt32 (FDT_MAGIC ))return 0 ;/* validate the ATAG */
Signature · 1 line
1.8.1.4
Quoted 7 lines · Kim Phillips
in preparation for the forthcoming dtc update which adds fdt specific
types: fdt{16,32,64}_t.Signed-off-by Kim Phillips <[email protected]>--- arch/arm/boot/compressed/libfdt_env.h | 4 ++++ include/linux/libfdt_env.h | 6 ++++++
We should kill off arch/arm/boot/compressed/libfdt_env.h and use include/linux/libfdt_env.h instead. The only reason I see why we have both is the ARM version was introduced before include/linux/libfdt_env.h existed.
Rob
Quoted 35 lines
2 files changed, 10 insertions(+)arch/arm/boot/compressed/libfdt_env.h +4
-0@@ -5,6 +5,10 @@#include <linux/string.h> #include <asm/byteorder.h> +typedef __be16 fdt16_t ; +typedef __be32 fdt32_t ; +typedef __be64 fdt64_t ; +#define fdt16_to_cpu (x) be16_to_cpu(x)#define cpu_to_fdt16 (x) cpu_to_be16(x)#define fdt32_to_cpu (x) be32_to_cpu(x)include/linux/libfdt_env.h +6
-0@@ -5,6 +5,12 @@#include <asm/byteorder.h> +typedef __be16 fdt16_t ; +typedef __be32 fdt32_t ; +typedef __be64 fdt64_t ; + +#define fdt16_to_cpu (x) be16_to_cpu(x) +#define cpu_to_fdt16 (x) cpu_to_be16(x)#define fdt32_to_cpu (x) be32_to_cpu(x)#define cpu_to_fdt32 (x) cpu_to_be32(x)#define fdt64_to_cpu (x) be64_to_cpu(x)