Skip to contentSkip to conversation

scripts/dtc: Update to upstream version v1.5.0-23-g87963ee20693

PATCH New Rob Herring 1 participant 1 message Jun 12, 2019 Device tree

lore
Share & tools
lore

Rob Herring

author maintainer
#0 lore raw

PATCH 1/1 scripts/dtc: Update to upstream version v1.5.0-23-g87963ee20693

This adds the following commits from upstream:

87963ee20693 livetree: add missing type markers in generated overlay properties 825146d13dc0 Fix typos in various documentation and source files 25bb080c18d1 Update the GPL2 text to the latest revision
243176c4ce84 Fix bogus error on rebuild
ce01b21098a4 libfdt: Add FDT_CREATE_FLAG_NO_NAME_DEDUP flag that trades size for speed fbb62754ce45 libfdt: Introduce fdt_create_with_flags()
228a44cce857 libfdt: Ensure fdt_add_property frees allocated name string on failure 8f695676227b Avoid assertion in check_interrupts_property()
5c3513f68921 Link tools and tests against libfdt shared library 00f9febf9c16 tests: Rename tests.sh to testutils.sh
c5d45188f923 Clean up LDLIBS handling
6ef8fcd05b74 Rebuild libfdt shared object if versioning linker script changes 26ee65a16c38 Use Python3 by default
cca6546244cb libfdt: Make fdt_get_max_phandle() an inline
730875016a6a libfdt: Add phandle generation helper
7dfb61ba96b1 libfdt: Use fdt_find_max_phandle()
2bc5b66d7f6c libfdt: Add new maximum phandle lookup function 7fcf8208b8a9 libfdt: add fdt_append_addrrange()
ae795b2db7a4 checks: Do not omit nodes with labels if symbol generation is requested eac2ad495b29 Update version.lds again
f67b47135523 Revert "libfdt: Add phandle generation helper"
54ea41c22415 libfdt: Add phandle generation helper
4762ad051ee0 checks: Fix spelling in check_graph_endpoint
d37f6b20107e Bump version to v1.5.0
a4b1a307ff3a pylibfdt:tests: Extend the way how to find a Python module 625dd8aaf20f pylibfdt: Change how passing tests are recognized 364631626bb7 pylibfdt: Test fdt.setprop take bytes on Python 3, add error handling cb0f454f73cc pylibfdt: check_err accepts only integer as a first argument. 4b68c6b3605a pylibfdt: Proper handling of bytes/unicode strings and octal literals 78e113e81c9d Use PRIxPTR for printing uintptr_t values
ea7a8f6dad67 libfdt: Fix FDT_ERR_NOTFOUND typos in documentation 5aafd7ca43e0 libfdt: Fix fdt_getprop_by_offset() parameter name in documentation 7cbc550f903b checks: Add unit address check if node is enabled

---
As usual, this patch is all the above upstream commits, so don't review the diff, just whether I ran the script to import correctly. :)

 scripts/dtc/checks.c               |  55 ++++++++--
 scripts/dtc/dtc.h                  |   3 +-
 scripts/dtc/flattree.c             |   2 +-
 scripts/dtc/libfdt/Makefile.libfdt |   2 +
 scripts/dtc/libfdt/fdt_addresses.c |  47 +++++++++
 scripts/dtc/libfdt/fdt_overlay.c   |  10 +-
 scripts/dtc/libfdt/fdt_ro.c        |  50 ++++++---
 scripts/dtc/libfdt/fdt_rw.c        |  22 +++-
 scripts/dtc/libfdt/fdt_strerror.c  |   1 +
 scripts/dtc/libfdt/fdt_sw.c        |  78 ++++++++++++--
 scripts/dtc/libfdt/libfdt.h        | 158 ++++++++++++++++++++++++++++-
 scripts/dtc/libfdt/libfdt_env.h    |   1 +
 scripts/dtc/livetree.c             |  20 ++--
 scripts/dtc/util.h                 |   4 +-
 scripts/dtc/version_gen.h          |   2 +-
 15 files changed, 399 insertions(+), 56 deletions(-)
scripts/dtc/checks.c +49 -6
index 4834e44b37b2..4719d658432b 100644
@@ -660,6 +660,8 @@ ERROR(path_references, fixup_path_references, NULL, &duplicate_node_names);
 static void fixup_omit_unused_nodes(struct check *c, struct dt_info *dti,
 				    struct node *node)
 {
+	if (generate_symbols && node->labels)
+		return;
 	if (node->omit_if_unused && !node->is_referenced)
 		delete_node(node);
 }
@@ -1212,8 +1214,24 @@ static void check_avoid_unnecessary_addr_size(struct check *c, struct dt_info *d
 }
 WARNING(avoid_unnecessary_addr_size, check_avoid_unnecessary_addr_size, NULL, &avoid_default_addr_size);
 
-static void check_unique_unit_address(struct check *c, struct dt_info *dti,
-					      struct node *node)
+static bool node_is_disabled(struct node *node)
+{
+	struct property *prop;
+
+	prop = get_property(node, "status");
+	if (prop) {
+		char *str = prop->val.val;
+		if (streq("disabled", str))
+			return true;
+	}
+
+	return false;
+}
+
+static void check_unique_unit_address_common(struct check *c,
+						struct dt_info *dti,
+						struct node *node,
+						bool disable_check)
 {
 	struct node *childa;
 
@@ -1230,18 +1248,38 @@ static void check_unique_unit_address(struct check *c, struct dt_info *dti,
 		if (!strlen(addr_a))
 			continue;
 
+		if (disable_check && node_is_disabled(childa))
+			continue;
+
 		for_each_child(node, childb) {
 			const char *addr_b = get_unitname(childb);
 			if (childa == childb)
 				break;
 
+			if (disable_check && node_is_disabled(childb))
+				continue;
+
 			if (streq(addr_a, addr_b))
 				FAIL(c, dti, childb, "duplicate unit-address (also used in node %s)", childa->fullpath);
 		}
 	}
 }
+
+static void check_unique_unit_address(struct check *c, struct dt_info *dti,
+					      struct node *node)
+{
+	check_unique_unit_address_common(c, dti, node, false);
+}
 WARNING(unique_unit_address, check_unique_unit_address, NULL, &avoid_default_addr_size);
 
+static void check_unique_unit_address_if_enabled(struct check *c, struct dt_info *dti,
+					      struct node *node)
+{
+	check_unique_unit_address_common(c, dti, node, true);
+}
+CHECK_ENTRY(unique_unit_address_if_enabled, check_unique_unit_address_if_enabled,
+	    NULL, false, false, &avoid_default_addr_size);
+
 static void check_obsolete_chosen_interrupt_controller(struct check *c,
 						       struct dt_info *dti,
 						       struct node *node)
@@ -1542,10 +1580,14 @@ static void check_interrupts_property(struct check *c,
 		prop = get_property(parent, "interrupt-parent");
 		if (prop) {
 			phandle = propval_cell(prop);
-			/* Give up if this is an overlay with external references */
-			if ((phandle == 0 || phandle == -1) &&
-			    (dti->dtsflags & DTSF_PLUGIN))
+			if ((phandle == 0) || (phandle == -1)) {
+				/* Give up if this is an overlay with
+				 * external references */
+				if (dti->dtsflags & DTSF_PLUGIN)
 					return;
+				FAIL_PROP(c, dti, parent, prop, "Invalid phandle");
+				continue;
+			}
 
 			irq_node = get_node_by_phandle(root, phandle);
 			if (!irq_node) {
@@ -1714,7 +1756,7 @@ static void check_graph_endpoint(struct check *c, struct dt_info *dti,
 		return;
 
 	if (!strprefixeq(node->name, node->basenamelen, "endpoint"))
-		FAIL(c, dti, node, "graph endpont node name should be 'endpoint'");
+		FAIL(c, dti, node, "graph endpoint node name should be 'endpoint'");
 
 	check_graph_reg(c, dti, node);
 
@@ -1769,6 +1811,7 @@ static struct check *check_table[] = {
 	&avoid_default_addr_size,
 	&avoid_unnecessary_addr_size,
 	&unique_unit_address,
+	&unique_unit_address_if_enabled,
 	&obsolete_chosen_interrupt_controller,
 	&chosen_node_is_root, &chosen_node_bootargs, &chosen_node_stdout_path,
 
scripts/dtc/dtc.h +2 -1
index 789e0b1bc057..0d5fa215ac87 100644
@@ -231,7 +231,8 @@ void add_child(struct node *parent, struct node *child);
 void delete_node_by_name(struct node *parent, char *name);
 void delete_node(struct node *node);
 void append_to_property(struct node *node,
-			char *name, const void *data, int len);
+			char *name, const void *data, int len,
+			enum markertype type);
 
 const char *get_unitname(struct node *node);
 struct property *get_property(struct node *node, const char *propname);
scripts/dtc/flattree.c +1 -1
index acf04c30669f..f7f70769d73f 100644
@@ -525,7 +525,7 @@ void dt_to_asm(FILE *f, struct dt_info *dti, int version)
 	fprintf(f, "/* Memory reserve map from source file */\n");
 
 	/*
-	 * Use .long on high and low halfs of u64s to avoid .quad
+	 * Use .long on high and low halves of u64s to avoid .quad
 	 * as it appears .quad isn't available in some assemblers.
 	 */
 	for (re = dti->reservelist; re; re = re->next) {
scripts/dtc/libfdt/Makefile.libfdt +2 -0
index 3af3656df801..193da8c99d83 100644
@@ -9,7 +9,9 @@ LIBFDT_VERSION = version.lds
 LIBFDT_SRCS = fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c fdt_empty_tree.c \
 	fdt_addresses.c fdt_overlay.c
 LIBFDT_OBJS = $(LIBFDT_SRCS:%.c=%.o)
+LIBFDT_LIB = libfdt-$(DTC_VERSION).$(SHAREDLIB_EXT)
 
 libfdt_clean:
 	@$(VECHO) CLEAN "(libfdt)"
 	rm -f $(STD_CLEANFILES:%=$(LIBFDT_dir)/%)
+	rm -f $(LIBFDT_dir)/$(LIBFDT_soname)
scripts/dtc/libfdt/fdt_addresses.c +47 -0

50 lines not on this page · raw message

scripts/dtc/libfdt/fdt_overlay.c +7 -3
index 5fdab6c6371d..d3e9ab2dbb7b 100644
@@ -93,11 +93,11 @@ static uint32_t overlay_get_target_phandle(const void *fdto, int fragment)
  * @pathp: pointer which receives the path of the target (or NULL)
  *
  * overlay_get_target() retrieves the target offset in the base
- * device tree of a fragment, no matter how the actual targetting is
+ * device tree of a fragment, no matter how the actual targeting is
  * done (through a phandle or a path)
  *
  * returns:
- *      the targetted node offset in the base device tree
+ *      the targeted node offset in the base device tree
  *      Negative error code on error
  */
 static int overlay_get_target(const void *fdt, const void *fdto,
@@ -863,12 +863,16 @@ static int overlay_symbol_update(void *fdt, void *fdto)
 
 int fdt_overlay_apply(void *fdt, void *fdto)
 {
-	uint32_t delta = fdt_get_max_phandle(fdt);
+	uint32_t delta;
 	int ret;
 
 	FDT_RO_PROBE(fdt);
 	FDT_RO_PROBE(fdto);
 
+	ret = fdt_find_max_phandle(fdt, &delta);
+	if (ret)
+		goto err;
+
 	ret = overlay_adjust_local_phandles(fdto, delta);
 	if (ret)
 		goto err;
scripts/dtc/libfdt/fdt_ro.c +35 -15

64 lines not on this page · raw message

scripts/dtc/libfdt/fdt_rw.c +19 -3
index 2e49855d7cf8..9e7661509e9f 100644
@@ -136,6 +136,14 @@ static int fdt_splice_struct_(void *fdt, void *p,
 	return 0;
 }
 
+/* Must only be used to roll back in case of error */
+static void fdt_del_last_string_(void *fdt, const char *s)
+{
+	int newlen = strlen(s) + 1;
+
+	fdt_set_size_dt_strings(fdt, fdt_size_dt_strings(fdt) - newlen);
+}
+
 static int fdt_splice_string_(void *fdt, int newlen)
 {
 	void *p = (char *)fdt
@@ -149,7 +157,7 @@ static int fdt_splice_string_(void *fdt, int newlen)
 	return 0;
 }
 
-static int fdt_find_add_string_(void *fdt, const char *s)
+static int fdt_find_add_string_(void *fdt, const char *s, int *allocated)
 {
 	char *strtab = (char *)fdt + fdt_off_dt_strings(fdt);
 	const char *p;
@@ -157,6 +165,8 @@ static int fdt_find_add_string_(void *fdt, const char *s)
 	int len = strlen(s) + 1;
 	int err;
 
+	*allocated = 0;
+
 	p = fdt_find_string_(strtab, fdt_size_dt_strings(fdt), s);
 	if (p)
 		/* found it */
@@ -167,6 +177,8 @@ static int fdt_find_add_string_(void *fdt, const char *s)
 	if (err)
 		return err;
 
+	*allocated = 1;
+
 	memcpy(new, s, len);
 	return (new - strtab);
 }
@@ -225,11 +237,12 @@ static int fdt_add_property_(void *fdt, int nodeoffset, const char *name,
 	int nextoffset;
 	int namestroff;
 	int err;
+	int allocated;
 
 	if ((nextoffset = fdt_check_node_offset_(fdt, nodeoffset)) < 0)
 		return nextoffset;
 
-	namestroff = fdt_find_add_string_(fdt, name);
+	namestroff = fdt_find_add_string_(fdt, name, &allocated);
 	if (namestroff < 0)
 		return namestroff;
 
@@ -237,8 +250,11 @@ static int fdt_add_property_(void *fdt, int nodeoffset, const char *name,
 	proplen = sizeof(**prop) + FDT_TAGALIGN(len);
 
 	err = fdt_splice_struct_(fdt, *prop, 0, proplen);
-	if (err)
+	if (err) {
+		if (allocated)
+			fdt_del_last_string_(fdt, name);
 		return err;
+	}
 
 	(*prop)->tag = cpu_to_fdt32(FDT_PROP);
 	(*prop)->nameoff = cpu_to_fdt32(namestroff);
scripts/dtc/libfdt/fdt_strerror.c +1 -0
index 9677a1887e57..0e6b4fd5e7ce 100644
@@ -82,6 +82,7 @@ static struct fdt_errtabent fdt_errtable[] = {
 	FDT_ERRTABENT(FDT_ERR_BADVALUE),
 	FDT_ERRTABENT(FDT_ERR_BADOVERLAY),
 	FDT_ERRTABENT(FDT_ERR_NOPHANDLES),
+	FDT_ERRTABENT(FDT_ERR_BADFLAGS),
 };
 #define FDT_ERRTABSIZE	(sizeof(fdt_errtable) / sizeof(fdt_errtable[0]))
 
scripts/dtc/libfdt/fdt_sw.c +67 -11

142 lines not on this page · raw message

scripts/dtc/libfdt/libfdt.h +153 -5

224 lines not on this page · raw message

scripts/dtc/libfdt/libfdt_env.h +1 -0
index eb2053845c9c..4d1cdfa58547 100644
@@ -52,6 +52,7 @@
  *     EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <stdbool.h>
 #include <stddef.h>
 #include <stdint.h>
 #include <stdlib.h>
scripts/dtc/livetree.c +12 -8
index 7a2e6446a17b..21c274125c2c 100644
@@ -249,6 +249,7 @@ struct node * add_orphan_node(struct node *dt, struct node *new_node, char *ref)
 	char *name;
 
 	if (ref[0] == '/') {
+		d = data_add_marker(d, TYPE_STRING, ref);
 		d = data_append_data(d, ref, strlen(ref) + 1);
 
 		p = build_property("target-path", d, NULL);
@@ -350,17 +351,20 @@ void delete_node(struct node *node)
 }
 
 void append_to_property(struct node *node,
-				    char *name, const void *data, int len)
+			char *name, const void *data, int len,
+			enum markertype type)
 {
 	struct data d;
 	struct property *p;
 
 	p = get_property(node, name);
 	if (p) {
-		d = data_append_data(p->val, data, len);
+		d = data_add_marker(p->val, type, name);
+		d = data_append_data(d, data, len);
 		p->val = d;
 	} else {
-		d = data_append_data(empty_data, data, len);
+		d = data_add_marker(empty_data, type, name);
+		d = data_append_data(d, data, len);
 		p = build_property(name, d, NULL);
 		add_property(node, p);
 	}
@@ -858,8 +862,8 @@ static void generate_label_tree_internal(struct dt_info *dti,
 
 			/* insert it */
 			p = build_property(l->label,
-				data_copy_mem(node->fullpath,
-						strlen(node->fullpath) + 1),
+				data_copy_escape_string(node->fullpath,
+						strlen(node->fullpath)),
 				NULL);
 			add_property(an, p);
 		}
@@ -910,7 +914,7 @@ static void add_fixup_entry(struct dt_info *dti, struct node *fn,
 
 	xasprintf(&entry, "%s:%s:%u",
 			node->fullpath, prop->name, m->offset);
-	append_to_property(fn, m->ref, entry, strlen(entry) + 1);
+	append_to_property(fn, m->ref, entry, strlen(entry) + 1, TYPE_STRING);
 
 	free(entry);
 }
@@ -970,7 +974,7 @@ static void add_local_fixup_entry(struct dt_info *dti,
 	char **compp;
 	int i, depth;
 
-	/* walk back retreiving depth */
+	/* walk back retrieving depth */
 	depth = 0;
 	for (wn = node; wn; wn = wn->parent)
 		depth++;
@@ -993,7 +997,7 @@ static void add_local_fixup_entry(struct dt_info *dti,
 	free(compp);
 
 	value_32 = cpu_to_fdt32(m->offset);
-	append_to_property(wn, prop->name, &value_32, sizeof(value_32));
+	append_to_property(wn, prop->name, &value_32, sizeof(value_32), TYPE_UINT32);
 }
 
 static void generate_local_fixups_tree_internal(struct dt_info *dti,
scripts/dtc/util.h +2 -2
index 7658781a6200..fc3c0d05ada3 100644
@@ -122,7 +122,7 @@ int utilfdt_read_err(const char *filename, char **buffp, size_t *len);
  * stderr.
  *
  * @param filename	The filename to write, or - for stdout
- * @param blob		Poiner to buffer containing fdt
+ * @param blob		Pointer to buffer containing fdt
  * @return 0 if ok, -1 on error
  */
 int utilfdt_write(const char *filename, const void *blob);
@@ -133,7 +133,7 @@ int utilfdt_write(const char *filename, const void *blob);
  * an error message for the user.
  *
  * @param filename	The filename to write, or - for stdout
- * @param blob		Poiner to buffer containing fdt
+ * @param blob		Pointer to buffer containing fdt
  * @return 0 if ok, else an errno value representing the error
  */
 int utilfdt_write_err(const char *filename, const void *blob);
scripts/dtc/version_gen.h +1 -1
index 75f383c0b9d3..2111a6e351f9 100644
@@ -1 +1 @@
-#define DTC_VERSION "DTC 1.4.7-gf267e674"
+#define DTC_VERSION "DTC 1.5.0-g87963ee2"
Signature · 1 line
2.20.1