Skip to content

Commit 7b2586a

Browse files
committed
scripts/dtc: Update to upstream version v1.4.6-21-g84e414b
This adds the following commits from upstream: 84e414b tests: Add a test case for the omit-if-no-ref keyword 4038fd9 dtc: add ability to make nodes conditional on them being referenced e1f139e checks: drop warning for missing PCI bridge bus-range f4eba68 checks: Print duplicate node name instead of parent name 46df1fb .travis.yml: Run valgrind checks via Travis 14a3002 tests: Update valgrind suppressions for sw_tree1 02c5fe9 tests: Remove valgrind error from tests/get_path df53683 checks: add graph binding checks 2347c96 checks: add a check for duplicate unit-addresses of child nodes 8f1b35f Correct overlay syntactic sugar for generating target-path fragments afbddcd Suppress warnings on overlay fragments 119e273 Improve tests for dtc overlay generation aadd0b6 checks: centralize printing of property names in failure messages 88960e3 checks: centralize printing of node path in check_msg f1879e1 Add limited read-only support for older (V2 and V3) device tree to libfdt. 37dea76 srcpos: drop special handling of tab 65893da libfdt: overlay: Add missing license 962a45c Avoid installing pylibfdt when dependencies are missing cd6ea1b Makefile: Split INSTALL out into INSTALL_{PROGRAM,LIB,DATA,SCRIPT} 51b3a16 Makefile.tests: Add LIBDL make(1) variable for portability sake 333d533 Attempt to auto-detect stat(1) being used if not given proper invocation e543880 dtc: Bump version to v1.4.6 a1fe86f fdtoverlay: Switch from using alloca to malloc c8d5472 tests: Improve compatibility with other platforms c81d389 checks: add chosen node checks e671852 checks: add aliases node checks d0c44eb checks: check for #{size,address}-cells without child nodes 18a3d84 checks: add string list check for *-names properties 8fe94fd checks: add string list check 6c57308 checks: add a string check for 'label' property a384191 checks: fix sound-dai phandle with arg property check b260c4f Fix ambiguous grammar for devicetree rule fe667e3 tests: Add some basic tests for the pci_bridge checks 7975f64 Fix widespread incorrect use of strneq(), replace with new strprefixeq() fca2964 Add strstarts() helper function cc392f0 tests: Check non-matching cases for fdt_node_check_compatible() bba26a5 livetree: avoid assertion of orphan phandles with overlays c8f8194 implement strnlen for systems that need it c8b38f6 libfdt: Remove leading underscores from identifiers 3b62fda Remove leading underscores from identifiers 2d45d1c Replace FDT_VERSION() with stringify() 2e6fe5a Fix some errors in comments b0ae9e4 tests: Correct warning in sw_tree1.c c1e55a5 checks: fix handling of unresolved phandles for dts plugins f8872e2 tests: Avoid 64-bit arithmetic in assembler 48c91c0 libfdt: add stringlist functions to linker script b1a6003 tests: Add a test for overlays syntactic sugar 737b2df overlay: Add syntactic sugar version of overlays 497432f checks: Use proper format modifier for size_t 22a65c5 dtc: Bump version to v1.4.5 c575d80 Add fdtoverlay to .gitignore b6a6f94 fdtoverlay: Sanity check blob size 8c1eb15 pylibfdt: Use Python2 explicitly ee3d26f checks: add interrupts property check c1e7738 checks: add gpio binding properties check b3bbac0 checks: add phandle with arg property checks fe50bd1 fdtget: Split out cell list display into a new function 62d8123 README: Add a note about test_tree1.dts 5bed86a pylibfdt: Add support for fdt_subnode_offset() 46f31b6 pylibfdt: Add support for fdt_node_offset_by_phandle() a3ae437 pylibfdt: Add support for fdt_parent_offset() a198af8 pylibfdt: Add support for fdt_get_phandle() b9eba92 tests: Return a failure code when any tests fail 155faf6 pylibfdt: Use local pylibfdt module 50e5cd0 pylibfdt: Add a test for use of uint32_t ab78860 pylibfdt: Add stdint include to fix uint32_t 36f511f tests: Add stacked overlay tests on fdtoverlay 1bb0065 fdt: Allow stacked overlays phandle references a33c224 Introduce fdt_setprop_placeholder() method 0016f8c dtc: change default phandles to ePAPR style instead of both e3b9a95 tests: fdtoverlay unit test 4240914 fdtoverlay: A tool that applies overlays aae2272 manual: Document missing options 13ce6e1 dtc: fix sprintf() format string error, again d990b80 Makefile: Fix build on MSYS2 and Cygwin 51f56de Clean up shared library compile/link options 21a2bc8 Suppress expected error message in fdtdump test 2a42b14 dtc: check.c fix compile error a10cb3c Fix get_node_by_path string equality check 548aea2 fdtdump: Discourage use of fdtdump c225884 fdtdump: Fix over-zealous version check 9067ee4 Fix a few whitespace and style nits e56f2b0 pylibfdt: Use setup.py to build the swig file 896f1c1 pylibfdt: Use Makefile constructs to implement NO_PYTHON 90db6d9 pylibfdt: Allow setup.py to operate stand-alone e20d965 Add Coverity Scan support b04a2cf pylibfdt: Fix code style in setup.py 1c5170d pylibfdt: Rename libfdt.swig to libfdt.i 580a9f6 Add a libfdt function to write a property placeholder ab15256 pylibfdt: Use the call function to simplify the Makefile 9f2e3a3 pylibfdt: Use the correct libfdt version in the module e91c652 pylibfdt: Enable installation of Python module 8a892fd pylibfdt: Allow building to be disabled 741cdff .travis.yml: Add builds with and without Python library prerequisites 14c4171 pylibfdt: Use package_dir to set the package directory 89a5062 pylibfdt: Use environment to pass C flags and files 4e0e0d0 pylibfdt: Allow pkg-config to be supplied in the environment 6afd7d9 Correct typo: s/pylibgfdt/pylibfdt/ Signed-off-by: Cristian Birsan <cristian.birsan@microchip.com>
1 parent a50e94d commit 7b2586a

24 files changed

Lines changed: 1892 additions & 898 deletions

scripts/dtc/checks.c

Lines changed: 749 additions & 123 deletions
Large diffs are not rendered by default.

scripts/dtc/dtc-lexer.l

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,13 @@ static void PRINTF(1, 2) lexical_error(const char *fmt, ...);
153153
return DT_DEL_NODE;
154154
}
155155

156+
<*>"/omit-if-no-ref/" {
157+
DPRINT("Keyword: /omit-if-no-ref/\n");
158+
DPRINT("<PROPNODENAME>\n");
159+
BEGIN(PROPNODENAME);
160+
return DT_OMIT_NO_REF;
161+
}
162+
156163
<*>{LABEL}: {
157164
DPRINT("Label: %s\n", yytext);
158165
yylval.labelref = xstrdup(yytext);

scripts/dtc/dtc-lexer.lex.c_shipped

Lines changed: 288 additions & 252 deletions
Large diffs are not rendered by default.

scripts/dtc/dtc-parser.tab.c_shipped

Lines changed: 392 additions & 337 deletions
Large diffs are not rendered by default.

scripts/dtc/dtc-parser.tab.h_shipped

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,15 @@ extern int yydebug;
5959
DT_BITS = 269,
6060
DT_DEL_PROP = 270,
6161
DT_DEL_NODE = 271,
62-
DT_PROPNODENAME = 272,
63-
DT_LITERAL = 273,
64-
DT_CHAR_LITERAL = 274,
65-
DT_BYTE = 275,
66-
DT_STRING = 276,
67-
DT_LABEL = 277,
68-
DT_REF = 278,
69-
DT_INCBIN = 279
62+
DT_OMIT_NO_REF = 272,
63+
DT_PROPNODENAME = 273,
64+
DT_LITERAL = 274,
65+
DT_CHAR_LITERAL = 275,
66+
DT_BYTE = 276,
67+
DT_STRING = 277,
68+
DT_LABEL = 278,
69+
DT_REF = 279,
70+
DT_INCBIN = 280
7071
};
7172
#endif
7273

@@ -95,7 +96,7 @@ union YYSTYPE
9596
uint64_t integer;
9697
unsigned int flags;
9798

98-
#line 99 "dtc-parser.tab.h" /* yacc.c:1909 */
99+
#line 100 "dtc-parser.tab.h" /* yacc.c:1909 */
99100
};
100101

101102
typedef union YYSTYPE YYSTYPE;

scripts/dtc/dtc-parser.y

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ extern bool treesource_error;
6363
%token DT_BITS
6464
%token DT_DEL_PROP
6565
%token DT_DEL_NODE
66+
%token DT_OMIT_NO_REF
6667
%token <propnodename> DT_PROPNODENAME
6768
%token <integer> DT_LITERAL
6869
%token <integer> DT_CHAR_LITERAL
@@ -166,7 +167,17 @@ devicetree:
166167
{
167168
$$ = merge_nodes($1, $3);
168169
}
169-
170+
| DT_REF nodedef
171+
{
172+
/*
173+
* We rely on the rule being always:
174+
* versioninfo plugindecl memreserves devicetree
175+
* so $-1 is what we want (plugindecl)
176+
*/
177+
if (!($<flags>-1 & DTSF_PLUGIN))
178+
ERROR(&@2, "Label or path %s not found", $1);
179+
$$ = add_orphan_node(name_node(build_node(NULL, NULL), ""), $2, $1);
180+
}
170181
| devicetree DT_LABEL DT_REF nodedef
171182
{
172183
struct node *target = get_node_by_ref($1, $3);
@@ -180,12 +191,21 @@ devicetree:
180191
}
181192
| devicetree DT_REF nodedef
182193
{
183-
struct node *target = get_node_by_ref($1, $2);
194+
/*
195+
* We rely on the rule being always:
196+
* versioninfo plugindecl memreserves devicetree
197+
* so $-1 is what we want (plugindecl)
198+
*/
199+
if ($<flags>-1 & DTSF_PLUGIN) {
200+
add_orphan_node($1, $3, $2);
201+
} else {
202+
struct node *target = get_node_by_ref($1, $2);
184203

185-
if (target)
186-
merge_nodes(target, $3);
187-
else
188-
ERROR(&@2, "Label or path %s not found", $2);
204+
if (target)
205+
merge_nodes(target, $3);
206+
else
207+
ERROR(&@2, "Label or path %s not found", $2);
208+
}
189209
$$ = $1;
190210
}
191211
| devicetree DT_DEL_NODE DT_REF ';'
@@ -198,6 +218,18 @@ devicetree:
198218
ERROR(&@3, "Label or path %s not found", $3);
199219

200220

221+
$$ = $1;
222+
}
223+
| devicetree DT_OMIT_NO_REF DT_REF ';'
224+
{
225+
struct node *target = get_node_by_ref($1, $3);
226+
227+
if (target)
228+
omit_node_if_unused(target);
229+
else
230+
ERROR(&@3, "Label or path %s not found", $3);
231+
232+
201233
$$ = $1;
202234
}
203235
;
@@ -504,6 +536,10 @@ subnode:
504536
{
505537
$$ = name_node(build_node_delete(), $2);
506538
}
539+
| DT_OMIT_NO_REF subnode
540+
{
541+
$$ = omit_node_if_unused($2);
542+
}
507543
| DT_LABEL subnode
508544
{
509545
add_label(&$2->labels, $1);

scripts/dtc/dtc.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ int reservenum; /* Number of memory reservation slots */
3131
int minsize; /* Minimum blob size */
3232
int padsize; /* Additional padding to blob */
3333
int alignsize; /* Additional padding to blob accroding to the alignsize */
34-
int phandle_format = PHANDLE_BOTH; /* Use linux,phandle or phandle properties */
34+
int phandle_format = PHANDLE_EPAPR; /* Use linux,phandle or phandle properties */
3535
int generate_symbols; /* enable symbols & fixup support */
3636
int generate_fixups; /* suppress generation of fixups on symbol support */
3737
int auto_label_aliases; /* auto generate labels -> aliases */
@@ -59,8 +59,6 @@ static void fill_fullpaths(struct node *tree, const char *prefix)
5959
}
6060

6161
/* Usage related data. */
62-
#define FDT_VERSION(version) _FDT_VERSION(version)
63-
#define _FDT_VERSION(version) #version
6462
static const char usage_synopsis[] = "dtc [options] <input file>";
6563
static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:a:fb:i:H:sW:E:@Ahv";
6664
static struct option const usage_long_opts[] = {
@@ -98,7 +96,7 @@ static const char * const usage_opts_help[] = {
9896
"\t\tdts - device tree source text\n"
9997
"\t\tdtb - device tree blob\n"
10098
"\t\tasm - assembler source",
101-
"\n\tBlob version to produce, defaults to "FDT_VERSION(DEFAULT_FDT_VERSION)" (for dtb and asm output)",
99+
"\n\tBlob version to produce, defaults to "stringify(DEFAULT_FDT_VERSION)" (for dtb and asm output)",
102100
"\n\tOutput dependency file",
103101
"\n\tMake space for <number> reserve map entries (for dtb and asm output)",
104102
"\n\tMake the blob at least <bytes> long (extra space)",
@@ -319,13 +317,14 @@ int main(int argc, char *argv[])
319317
dti->boot_cpuid_phys = cmdline_boot_cpuid;
320318

321319
fill_fullpaths(dti->dt, "");
322-
process_checks(force, dti);
323320

324321
/* on a plugin, generate by default */
325322
if (dti->dtsflags & DTSF_PLUGIN) {
326323
generate_fixups = 1;
327324
}
328325

326+
process_checks(force, dti);
327+
329328
if (auto_label_aliases)
330329
generate_label_tree(dti, "aliases", false);
331330

scripts/dtc/dtc.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef _DTC_H
2-
#define _DTC_H
1+
#ifndef DTC_H
2+
#define DTC_H
33

44
/*
55
* (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
@@ -31,6 +31,7 @@
3131
#include <ctype.h>
3232
#include <errno.h>
3333
#include <unistd.h>
34+
#include <inttypes.h>
3435

3536
#include <libfdt_env.h>
3637
#include <fdt.h>
@@ -66,7 +67,8 @@ typedef uint32_t cell_t;
6667

6768

6869
#define streq(a, b) (strcmp((a), (b)) == 0)
69-
#define strneq(a, b, n) (strncmp((a), (b), (n)) == 0)
70+
#define strstarts(s, prefix) (strncmp((s), (prefix), strlen(prefix)) == 0)
71+
#define strprefixeq(a, n, b) (strlen(b) == (n) && (memcmp(a, b, n) == 0))
7072

7173
#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
7274

@@ -166,6 +168,8 @@ struct node {
166168

167169
struct label *labels;
168170
const struct bus_type *bus;
171+
172+
bool omit_if_unused, is_referenced;
169173
};
170174

171175
#define for_each_label_withdel(l0, l) \
@@ -200,8 +204,11 @@ struct property *reverse_properties(struct property *first);
200204
struct node *build_node(struct property *proplist, struct node *children);
201205
struct node *build_node_delete(void);
202206
struct node *name_node(struct node *node, char *name);
207+
struct node *omit_node_if_unused(struct node *node);
208+
struct node *reference_node(struct node *node);
203209
struct node *chain_node(struct node *first, struct node *list);
204210
struct node *merge_nodes(struct node *old_node, struct node *new_node);
211+
struct node *add_orphan_node(struct node *old_node, struct node *new_node, char *ref);
205212

206213
void add_property(struct node *node, struct property *prop);
207214
void delete_property_by_name(struct node *node, char *name);
@@ -215,6 +222,7 @@ void append_to_property(struct node *node,
215222
const char *get_unitname(struct node *node);
216223
struct property *get_property(struct node *node, const char *propname);
217224
cell_t propval_cell(struct property *prop);
225+
cell_t propval_cell_n(struct property *prop, int n);
218226
struct property *get_property_by_label(struct node *tree, const char *label,
219227
struct node **node);
220228
struct marker *get_marker_label(struct node *tree, const char *label,
@@ -286,4 +294,4 @@ struct dt_info *dt_from_source(const char *f);
286294

287295
struct dt_info *dt_from_fs(const char *dirname);
288296

289-
#endif /* _DTC_H */
297+
#endif /* DTC_H */

scripts/dtc/flattree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ static char *nodename_from_path(const char *ppath, const char *cpath)
731731

732732
plen = strlen(ppath);
733733

734-
if (!strneq(ppath, cpath, plen))
734+
if (!strstarts(cpath, ppath))
735735
die("Path \"%s\" is not valid as a child of \"%s\"\n",
736736
cpath, ppath);
737737

scripts/dtc/libfdt/fdt.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len)
8888
|| ((offset + len) > fdt_size_dt_struct(fdt)))
8989
return NULL;
9090

91-
return _fdt_offset_ptr(fdt, offset);
91+
return fdt_offset_ptr_(fdt, offset);
9292
}
9393

9494
uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)
@@ -123,6 +123,9 @@ uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)
123123
/* skip-name offset, length and value */
124124
offset += sizeof(struct fdt_property) - FDT_TAGSIZE
125125
+ fdt32_to_cpu(*lenp);
126+
if (fdt_version(fdt) < 0x10 && fdt32_to_cpu(*lenp) >= 8 &&
127+
((offset - fdt32_to_cpu(*lenp)) % 8) != 0)
128+
offset += 4;
126129
break;
127130

128131
case FDT_END:
@@ -141,7 +144,7 @@ uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)
141144
return tag;
142145
}
143146

144-
int _fdt_check_node_offset(const void *fdt, int offset)
147+
int fdt_check_node_offset_(const void *fdt, int offset)
145148
{
146149
if ((offset < 0) || (offset % FDT_TAGSIZE)
147150
|| (fdt_next_tag(fdt, offset, &offset) != FDT_BEGIN_NODE))
@@ -150,7 +153,7 @@ int _fdt_check_node_offset(const void *fdt, int offset)
150153
return offset;
151154
}
152155

153-
int _fdt_check_prop_offset(const void *fdt, int offset)
156+
int fdt_check_prop_offset_(const void *fdt, int offset)
154157
{
155158
if ((offset < 0) || (offset % FDT_TAGSIZE)
156159
|| (fdt_next_tag(fdt, offset, &offset) != FDT_PROP))
@@ -165,7 +168,7 @@ int fdt_next_node(const void *fdt, int offset, int *depth)
165168
uint32_t tag;
166169

167170
if (offset >= 0)
168-
if ((nextoffset = _fdt_check_node_offset(fdt, offset)) < 0)
171+
if ((nextoffset = fdt_check_node_offset_(fdt, offset)) < 0)
169172
return nextoffset;
170173

171174
do {
@@ -227,7 +230,7 @@ int fdt_next_subnode(const void *fdt, int offset)
227230
return offset;
228231
}
229232

230-
const char *_fdt_find_string(const char *strtab, int tabsize, const char *s)
233+
const char *fdt_find_string_(const char *strtab, int tabsize, const char *s)
231234
{
232235
int len = strlen(s) + 1;
233236
const char *last = strtab + tabsize - len;

0 commit comments

Comments
 (0)