aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/dtc/libfdt
diff options
context:
space:
mode:
authorRob Herring <robh@kernel.org>2017-03-21 10:01:08 -0400
committerRob Herring <robh@kernel.org>2017-03-22 15:56:14 -0400
commit89d123106a97bf412a4c10482044c822f4b069f7 (patch)
tree35603f528aedddff67a643b957f2803601a03f95 /scripts/dtc/libfdt
parent86cef6144d273404d8cb5c0b215ada8d23e5dbeb (diff)
scripts/dtc: Update to upstream version v1.4.4-8-g756ffc4f52f6
This adds the following commits from upstream: 756ffc4f52f6 Build pylibfdt as part of the normal build process 8cb3896358e9 Adjust libfdt.h to work with swig b40aa8359aff Mention pylibfdt in the documentation 12cfb740cc76 Add tests for pylibfdt 50f250701631 Add an initial Python library for libfdt cdbb2b6c7a3a checks: Warn on node name unit-addresses with '0x' or leading 0s 4c15d5da17cc checks: Add bus checks for simple-bus buses 33c3985226d3 checks: Add bus checks for PCI buses 558cd81bdd43 dtc: Bump version to v1.4.4 c17a811c62eb fdtput: Remove star from value_len documentation 194d5caaefcb fdtget: Use @return to document the return value d922ecdd017b tests: Make realloc_fdt() really allocate *fdt 921cc17fec29 libfdt: overlay: Check the value of the right variable 9ffdf60bf463 dtc: Simplify asm_emit_string() implementation 881012e44386 libfdt: Change names of sparse helper macros bad5b28049e5 Fix assorted sparse warnings 672ac09ea04d Clean up gcc attributes 49300f2ade6a dtc: Don't abuse struct fdt_reserve_entry fa8bc7f928ac dtc: Bump version to v1.4.3 34a9886a177f Add printf format attributes f72508e2b6ca Correct some broken printf() like format mismatches 397d5ef0203c libfdt: Add fdt_setprop_empty() 69a1bd6ad3f9 libfdt: Remove undefined behaviour setting empty properties acd1b534a592 Print output filename as part of warning messages 120775eb1cf3 dtc: Use streq() in preference to strcmp() 852e9ecbe197 checks: Add Warning for stricter node name character checking ef0e8f061534 checks: Add Warning for stricter property name character checking 00d7bb1f4b0e dtc: pos parameter to srcpos_string() can't be NULL 95d57726bca4 livetree.c: Fix memory leak 3b9c97093d6e dtc: Fix NULL pointer use in dtlabel + dtref case 43eb551426ea manual: Fix typo it -> in 4baf15f7f13f Makefile: Add tags rule Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'scripts/dtc/libfdt')
-rw-r--r--scripts/dtc/libfdt/fdt_rw.c3
-rw-r--r--scripts/dtc/libfdt/libfdt.h51
-rw-r--r--scripts/dtc/libfdt/libfdt_env.h26
3 files changed, 65 insertions, 15 deletions
diff --git a/scripts/dtc/libfdt/fdt_rw.c b/scripts/dtc/libfdt/fdt_rw.c
index 2eed4f58387c..3fd5847377c9 100644
--- a/scripts/dtc/libfdt/fdt_rw.c
+++ b/scripts/dtc/libfdt/fdt_rw.c
@@ -283,7 +283,8 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
283 if (err) 283 if (err)
284 return err; 284 return err;
285 285
286 memcpy(prop->data, val, len); 286 if (len)
287 memcpy(prop->data, val, len);
287 return 0; 288 return 0;
288} 289}
289 290
diff --git a/scripts/dtc/libfdt/libfdt.h b/scripts/dtc/libfdt/libfdt.h
index b842b156fa17..ba86caa73d01 100644
--- a/scripts/dtc/libfdt/libfdt.h
+++ b/scripts/dtc/libfdt/libfdt.h
@@ -143,7 +143,9 @@
143/* Low-level functions (you probably don't need these) */ 143/* Low-level functions (you probably don't need these) */
144/**********************************************************************/ 144/**********************************************************************/
145 145
146#ifndef SWIG /* This function is not useful in Python */
146const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int checklen); 147const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int checklen);
148#endif
147static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen) 149static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen)
148{ 150{
149 return (void *)(uintptr_t)fdt_offset_ptr(fdt, offset, checklen); 151 return (void *)(uintptr_t)fdt_offset_ptr(fdt, offset, checklen);
@@ -210,7 +212,6 @@ int fdt_next_subnode(const void *fdt, int offset);
210/**********************************************************************/ 212/**********************************************************************/
211/* General functions */ 213/* General functions */
212/**********************************************************************/ 214/**********************************************************************/
213
214#define fdt_get_header(fdt, field) \ 215#define fdt_get_header(fdt, field) \
215 (fdt32_to_cpu(((const struct fdt_header *)(fdt))->field)) 216 (fdt32_to_cpu(((const struct fdt_header *)(fdt))->field))
216#define fdt_magic(fdt) (fdt_get_header(fdt, magic)) 217#define fdt_magic(fdt) (fdt_get_header(fdt, magic))
@@ -354,8 +355,10 @@ int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size);
354 * useful for finding subnodes based on a portion of a larger string, 355 * useful for finding subnodes based on a portion of a larger string,
355 * such as a full path. 356 * such as a full path.
356 */ 357 */
358#ifndef SWIG /* Not available in Python */
357int fdt_subnode_offset_namelen(const void *fdt, int parentoffset, 359int fdt_subnode_offset_namelen(const void *fdt, int parentoffset,
358 const char *name, int namelen); 360 const char *name, int namelen);
361#endif
359/** 362/**
360 * fdt_subnode_offset - find a subnode of a given node 363 * fdt_subnode_offset - find a subnode of a given node
361 * @fdt: pointer to the device tree blob 364 * @fdt: pointer to the device tree blob
@@ -391,7 +394,9 @@ int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name);
391 * Identical to fdt_path_offset(), but only consider the first namelen 394 * Identical to fdt_path_offset(), but only consider the first namelen
392 * characters of path as the path name. 395 * characters of path as the path name.
393 */ 396 */
397#ifndef SWIG /* Not available in Python */
394int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen); 398int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen);
399#endif
395 400
396/** 401/**
397 * fdt_path_offset - find a tree node by its full path 402 * fdt_path_offset - find a tree node by its full path
@@ -550,10 +555,12 @@ const struct fdt_property *fdt_get_property_by_offset(const void *fdt,
550 * Identical to fdt_get_property(), but only examine the first namelen 555 * Identical to fdt_get_property(), but only examine the first namelen
551 * characters of name for matching the property name. 556 * characters of name for matching the property name.
552 */ 557 */
558#ifndef SWIG /* Not available in Python */
553const struct fdt_property *fdt_get_property_namelen(const void *fdt, 559const struct fdt_property *fdt_get_property_namelen(const void *fdt,
554 int nodeoffset, 560 int nodeoffset,
555 const char *name, 561 const char *name,
556 int namelen, int *lenp); 562 int namelen, int *lenp);
563#endif
557 564
558/** 565/**
559 * fdt_get_property - find a given property in a given node 566 * fdt_get_property - find a given property in a given node
@@ -624,8 +631,10 @@ static inline struct fdt_property *fdt_get_property_w(void *fdt, int nodeoffset,
624 * -FDT_ERR_BADSTRUCTURE, 631 * -FDT_ERR_BADSTRUCTURE,
625 * -FDT_ERR_TRUNCATED, standard meanings 632 * -FDT_ERR_TRUNCATED, standard meanings
626 */ 633 */
634#ifndef SWIG /* This function is not useful in Python */
627const void *fdt_getprop_by_offset(const void *fdt, int offset, 635const void *fdt_getprop_by_offset(const void *fdt, int offset,
628 const char **namep, int *lenp); 636 const char **namep, int *lenp);
637#endif
629 638
630/** 639/**
631 * fdt_getprop_namelen - get property value based on substring 640 * fdt_getprop_namelen - get property value based on substring
@@ -638,6 +647,7 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset,
638 * Identical to fdt_getprop(), but only examine the first namelen 647 * Identical to fdt_getprop(), but only examine the first namelen
639 * characters of name for matching the property name. 648 * characters of name for matching the property name.
640 */ 649 */
650#ifndef SWIG /* Not available in Python */
641const void *fdt_getprop_namelen(const void *fdt, int nodeoffset, 651const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
642 const char *name, int namelen, int *lenp); 652 const char *name, int namelen, int *lenp);
643static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset, 653static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset,
@@ -647,6 +657,7 @@ static inline void *fdt_getprop_namelen_w(void *fdt, int nodeoffset,
647 return (void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name, 657 return (void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name,
648 namelen, lenp); 658 namelen, lenp);
649} 659}
660#endif
650 661
651/** 662/**
652 * fdt_getprop - retrieve the value of a given property 663 * fdt_getprop - retrieve the value of a given property
@@ -707,8 +718,10 @@ uint32_t fdt_get_phandle(const void *fdt, int nodeoffset);
707 * Identical to fdt_get_alias(), but only examine the first namelen 718 * Identical to fdt_get_alias(), but only examine the first namelen
708 * characters of name for matching the alias name. 719 * characters of name for matching the alias name.
709 */ 720 */
721#ifndef SWIG /* Not available in Python */
710const char *fdt_get_alias_namelen(const void *fdt, 722const char *fdt_get_alias_namelen(const void *fdt,
711 const char *name, int namelen); 723 const char *name, int namelen);
724#endif
712 725
713/** 726/**
714 * fdt_get_alias - retrieve the path referenced by a given alias 727 * fdt_get_alias - retrieve the path referenced by a given alias
@@ -1106,10 +1119,12 @@ int fdt_size_cells(const void *fdt, int nodeoffset);
1106 * of the name. It is useful when you want to manipulate only one value of 1119 * of the name. It is useful when you want to manipulate only one value of
1107 * an array and you have a string that doesn't end with \0. 1120 * an array and you have a string that doesn't end with \0.
1108 */ 1121 */
1122#ifndef SWIG /* Not available in Python */
1109int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset, 1123int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset,
1110 const char *name, int namelen, 1124 const char *name, int namelen,
1111 uint32_t idx, const void *val, 1125 uint32_t idx, const void *val,
1112 int len); 1126 int len);
1127#endif
1113 1128
1114/** 1129/**
1115 * fdt_setprop_inplace - change a property's value, but not its size 1130 * fdt_setprop_inplace - change a property's value, but not its size
@@ -1139,8 +1154,10 @@ int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset,
1139 * -FDT_ERR_BADSTRUCTURE, 1154 * -FDT_ERR_BADSTRUCTURE,
1140 * -FDT_ERR_TRUNCATED, standard meanings 1155 * -FDT_ERR_TRUNCATED, standard meanings
1141 */ 1156 */
1157#ifndef SWIG /* Not available in Python */
1142int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name, 1158int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
1143 const void *val, int len); 1159 const void *val, int len);
1160#endif
1144 1161
1145/** 1162/**
1146 * fdt_setprop_inplace_u32 - change the value of a 32-bit integer property 1163 * fdt_setprop_inplace_u32 - change the value of a 32-bit integer property
@@ -1527,6 +1544,36 @@ static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name,
1527#define fdt_setprop_string(fdt, nodeoffset, name, str) \ 1544#define fdt_setprop_string(fdt, nodeoffset, name, str) \
1528 fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1) 1545 fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)
1529 1546
1547
1548/**
1549 * fdt_setprop_empty - set a property to an empty value
1550 * @fdt: pointer to the device tree blob
1551 * @nodeoffset: offset of the node whose property to change
1552 * @name: name of the property to change
1553 *
1554 * fdt_setprop_empty() sets the value of the named property in the
1555 * given node to an empty (zero length) value, or creates a new empty
1556 * property if it does not already exist.
1557 *
1558 * This function may insert or delete data from the blob, and will
1559 * therefore change the offsets of some existing nodes.
1560 *
1561 * returns:
1562 * 0, on success
1563 * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
1564 * contain the new property value
1565 * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
1566 * -FDT_ERR_BADLAYOUT,
1567 * -FDT_ERR_BADMAGIC,
1568 * -FDT_ERR_BADVERSION,
1569 * -FDT_ERR_BADSTATE,
1570 * -FDT_ERR_BADSTRUCTURE,
1571 * -FDT_ERR_BADLAYOUT,
1572 * -FDT_ERR_TRUNCATED, standard meanings
1573 */
1574#define fdt_setprop_empty(fdt, nodeoffset, name) \
1575 fdt_setprop((fdt), (nodeoffset), (name), NULL, 0)
1576
1530/** 1577/**
1531 * fdt_appendprop - append to or create a property 1578 * fdt_appendprop - append to or create a property
1532 * @fdt: pointer to the device tree blob 1579 * @fdt: pointer to the device tree blob
@@ -1704,8 +1751,10 @@ int fdt_delprop(void *fdt, int nodeoffset, const char *name);
1704 * creating subnodes based on a portion of a larger string, such as a 1751 * creating subnodes based on a portion of a larger string, such as a
1705 * full path. 1752 * full path.
1706 */ 1753 */
1754#ifndef SWIG /* Not available in Python */
1707int fdt_add_subnode_namelen(void *fdt, int parentoffset, 1755int fdt_add_subnode_namelen(void *fdt, int parentoffset,
1708 const char *name, int namelen); 1756 const char *name, int namelen);
1757#endif
1709 1758
1710/** 1759/**
1711 * fdt_add_subnode - creates a new node 1760 * fdt_add_subnode - creates a new node
diff --git a/scripts/dtc/libfdt/libfdt_env.h b/scripts/dtc/libfdt/libfdt_env.h
index 99f936dacc60..952056cddf09 100644
--- a/scripts/dtc/libfdt/libfdt_env.h
+++ b/scripts/dtc/libfdt/libfdt_env.h
@@ -58,16 +58,16 @@
58#include <string.h> 58#include <string.h>
59 59
60#ifdef __CHECKER__ 60#ifdef __CHECKER__
61#define __force __attribute__((force)) 61#define FDT_FORCE __attribute__((force))
62#define __bitwise __attribute__((bitwise)) 62#define FDT_BITWISE __attribute__((bitwise))
63#else 63#else
64#define __force 64#define FDT_FORCE
65#define __bitwise 65#define FDT_BITWISE
66#endif 66#endif
67 67
68typedef uint16_t __bitwise fdt16_t; 68typedef uint16_t FDT_BITWISE fdt16_t;
69typedef uint32_t __bitwise fdt32_t; 69typedef uint32_t FDT_BITWISE fdt32_t;
70typedef uint64_t __bitwise fdt64_t; 70typedef uint64_t FDT_BITWISE fdt64_t;
71 71
72#define EXTRACT_BYTE(x, n) ((unsigned long long)((uint8_t *)&x)[n]) 72#define EXTRACT_BYTE(x, n) ((unsigned long long)((uint8_t *)&x)[n])
73#define CPU_TO_FDT16(x) ((EXTRACT_BYTE(x, 0) << 8) | EXTRACT_BYTE(x, 1)) 73#define CPU_TO_FDT16(x) ((EXTRACT_BYTE(x, 0) << 8) | EXTRACT_BYTE(x, 1))
@@ -80,29 +80,29 @@ typedef uint64_t __bitwise fdt64_t;
80 80
81static inline uint16_t fdt16_to_cpu(fdt16_t x) 81static inline uint16_t fdt16_to_cpu(fdt16_t x)
82{ 82{
83 return (__force uint16_t)CPU_TO_FDT16(x); 83 return (FDT_FORCE uint16_t)CPU_TO_FDT16(x);
84} 84}
85static inline fdt16_t cpu_to_fdt16(uint16_t x) 85static inline fdt16_t cpu_to_fdt16(uint16_t x)
86{ 86{
87 return (__force fdt16_t)CPU_TO_FDT16(x); 87 return (FDT_FORCE fdt16_t)CPU_TO_FDT16(x);
88} 88}
89 89
90static inline uint32_t fdt32_to_cpu(fdt32_t x) 90static inline uint32_t fdt32_to_cpu(fdt32_t x)
91{ 91{
92 return (__force uint32_t)CPU_TO_FDT32(x); 92 return (FDT_FORCE uint32_t)CPU_TO_FDT32(x);
93} 93}
94static inline fdt32_t cpu_to_fdt32(uint32_t x) 94static inline fdt32_t cpu_to_fdt32(uint32_t x)
95{ 95{
96 return (__force fdt32_t)CPU_TO_FDT32(x); 96 return (FDT_FORCE fdt32_t)CPU_TO_FDT32(x);
97} 97}
98 98
99static inline uint64_t fdt64_to_cpu(fdt64_t x) 99static inline uint64_t fdt64_to_cpu(fdt64_t x)
100{ 100{
101 return (__force uint64_t)CPU_TO_FDT64(x); 101 return (FDT_FORCE uint64_t)CPU_TO_FDT64(x);
102} 102}
103static inline fdt64_t cpu_to_fdt64(uint64_t x) 103static inline fdt64_t cpu_to_fdt64(uint64_t x)
104{ 104{
105 return (__force fdt64_t)CPU_TO_FDT64(x); 105 return (FDT_FORCE fdt64_t)CPU_TO_FDT64(x);
106} 106}
107#undef CPU_TO_FDT64 107#undef CPU_TO_FDT64
108#undef CPU_TO_FDT32 108#undef CPU_TO_FDT32