]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
scripts/dtc: Update to upstream version v1.7.2-35-g52f07dcca47c
authorRob Herring (Arm) <robh@kernel.org>
Fri, 25 Jul 2025 20:06:26 +0000 (15:06 -0500)
committerRob Herring (Arm) <robh@kernel.org>
Mon, 11 Aug 2025 13:08:51 +0000 (08:08 -0500)
This adds the following commits from upstream:

52f07dcca47c dtc: Add informative error for stray identifier
9cabae6b0351 checks: Fix detection of 'i2c-bus' node
605dc044c3fe New helper to add markers
7da5d106c740 fdtput: Fix documentation about existing nodes
53c63dd421d7 dtdiff: Use input format dtb for dtbo files
84d9dd2fcbc8 dtc: Add data_insert_data function
97011d1f4e98 meson: use override_find_program/override_dependency
b841391bbd08 srcpos: Define srcpos_free
e0b7749c26a9 Add alloc_marker
ecb21febfdd3 meson: port python bindings to build natively via meson and meson-python
7ebfcac8520e Makefile: deprecate in favor of Meson
f4c53f4ebf78 Use __ASSEMBLER__ instead of __ASSEMBLY__
205fbef17b7b Fix some typos
da85f91931e5 Remove duplicated words in documentation and comments
dd1b3e532d22 meson: support building libfdt without static library
1ccd232709d4 meson: don't build test programs by default
ce1d8588880a tests: When building .so from -O asm output mark as non-executable stack
915daadbb62d Start with empty __local_fixups__ and __fixups__ nodes
4ea851f5a44d Let get_subnode() not return deleted nodes
175d2a564c47 Use build_root_node() instead of open-coding it
18f4f305fdd7 build: fix -Dtools=false build
267efc7d4694 checks: Warn about missing #address-cells for interrupt parents
755db115355b libfdt: Add fdt_setprop_namelen_string()
bdca8612009e libfdt: Add fdt_setprop_namelen()
0f69cedc08fc libfdt_internal: fdt_find_string_len_()
56b2b30c5bd0 libfdt: add fdt_get_property_namelen_w()
1e8c5f60e127 Add clang-format config
6f183c7d9246 checks: Relax avoid_unnecessary_addr_size check to allow child ranges properties
66c7d0e6f4f3 tests/sw_tree1.c: fix unitialized saveptr
9a969f3b70b0 pylibfdt/libfdt.i: fix backwards compatibility of return values
4292b072a23a .github/workflows: update ubuntu runner to supported version
1c745a9bd169 libfdt: Remove fdt parameter from overlay_fixup_one_phandle
b3bbee6b1242 libfdt: Move the SBOM authors section
d1656730abfb Add a SBOM file in CycloneDX format
b75515af4576 libfdt: Remove extra semi-colons outside functions
2d10aa2afe35 Bump version to v1.7.2
48795c82bdb6 pylibfdt: Don't emit warnings from swig generate C code
838f11e830e3 fdtoverlay: provide better error message for missing `/__symbols__`
d1e2384185c5 pylibfdt/libfdt.i: Use SWIG_AppendOutput
18aa49a9f68d Escape spaces in depfile with backslashes.
f9968fa06921 libfdt.h: whitespace consistency fixups
9b5f65fb3d8d libfdt.h: typo and consistency fixes
99031e3a4a6e Bump version to v1.7.1
3d5e376925fd setup: Move setting of srcdir down to the bottom
e277553b9880 setup: Collect top-level code together
7e5a88984081 setup: Move version and full_description into a function
78b6a85c113b Tidy up some pylint warnings
3501d373f0a2 Require Python 3

The added include of string.h in libfdt_internal.h breaks the kernel
overriding libfdt_env.h with its own string functions, so it is dropped.
An upstream fix is pending.

Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
21 files changed:
scripts/Makefile.dtbs
scripts/dtc/checks.c
scripts/dtc/data.c
scripts/dtc/dtc-lexer.l
scripts/dtc/dtc.c
scripts/dtc/dtc.h
scripts/dtc/fdtoverlay.c
scripts/dtc/flattree.c
scripts/dtc/libfdt/fdt.c
scripts/dtc/libfdt/fdt.h
scripts/dtc/libfdt/fdt_overlay.c
scripts/dtc/libfdt/fdt_rw.c
scripts/dtc/libfdt/libfdt.h
scripts/dtc/libfdt/libfdt_internal.h
scripts/dtc/livetree.c
scripts/dtc/srcpos.c
scripts/dtc/srcpos.h
scripts/dtc/treesource.c
scripts/dtc/util.c
scripts/dtc/util.h
scripts/dtc/version_gen.h

index 8d56c0815f338f053f622108f49e7f054cc52f9f..2d321b813600e910c34c9bc446b808fb68f93bf2 100644 (file)
@@ -97,6 +97,7 @@ DTC_FLAGS += -Wno-unit_address_vs_reg \
              -Wno-avoid_unnecessary_addr_size \
              -Wno-alias_paths \
              -Wno-graph_child_address \
+             -Wno-interrupt_map \
              -Wno-simple_bus_reg
 else
 DTC_FLAGS += -Wunique_unit_address_if_enabled
index 6e06aeab5503f78c8a969f8d1d0e96be7b91749e..7e3fed5005b310a69701e5a235f7afdd98aa6f86 100644 (file)
@@ -1024,7 +1024,7 @@ static void check_i2c_bus_bridge(struct check *c, struct dt_info *dti, struct no
        } else if (strprefixeq(node->name, node->basenamelen, "i2c")) {
                struct node *child;
                for_each_child(node, child) {
-                       if (strprefixeq(child->name, node->basenamelen, "i2c-bus"))
+                       if (strprefixeq(child->name, child->basenamelen, "i2c-bus"))
                                return;
                }
                node->bus = &i2c_bus;
@@ -1217,9 +1217,7 @@ WARNING(avoid_default_addr_size, check_avoid_default_addr_size, NULL,
 static void check_avoid_unnecessary_addr_size(struct check *c, struct dt_info *dti,
                                              struct node *node)
 {
-       struct property *prop;
        struct node *child;
-       bool has_reg = false;
 
        if (!node->parent || node->addr_cells < 0 || node->size_cells < 0)
                return;
@@ -1228,13 +1226,18 @@ static void check_avoid_unnecessary_addr_size(struct check *c, struct dt_info *d
                return;
 
        for_each_child(node, child) {
-               prop = get_property(child, "reg");
-               if (prop)
-                       has_reg = true;
+               /*
+                * Even if the child devices' address space is not mapped into
+                * the parent bus (no 'ranges' property on node), children can
+                * still have registers on a local bus, or map local addresses
+                * to another subordinate address space. The properties on the
+                * child nodes then make #address-cells/#size-cells necessary:
+                */
+               if (get_property(child, "reg") || get_property(child, "ranges"))
+                       return;
        }
 
-       if (!has_reg)
-               FAIL(c, dti, node, "unnecessary #address-cells/#size-cells without \"ranges\", \"dma-ranges\" or child \"reg\" property");
+       FAIL(c, dti, node, "unnecessary #address-cells/#size-cells without \"ranges\", \"dma-ranges\" or child \"reg\" or \"ranges\" property");
 }
 WARNING(avoid_unnecessary_addr_size, check_avoid_unnecessary_addr_size, NULL, &avoid_default_addr_size);
 
@@ -1673,6 +1676,10 @@ static void check_interrupt_map(struct check *c,
                cellprop = get_property(provider_node, "#address-cells");
                if (cellprop)
                        parent_cellsize += propval_cell(cellprop);
+               else
+                       FAIL_PROP(c, dti, node, irq_map_prop,
+                               "Missing property '#address-cells' in node %s, using 0 as fallback",
+                               provider_node->fullpath);
 
                cell += 1 + parent_cellsize;
                if (cell > map_cells)
index 14734233ad8b7ebd38c3e62442b81aae66601806..5b25aa060416134be430aebe33c9cce49515297f 100644 (file)
@@ -228,11 +228,7 @@ struct data data_add_marker(struct data d, enum markertype type, char *ref)
 {
        struct marker *m;
 
-       m = xmalloc(sizeof(*m));
-       m->offset = d.len;
-       m->type = type;
-       m->ref = ref;
-       m->next = NULL;
+       m = alloc_marker(d.len, type, ref);
 
        return data_append_markers(d, m);
 }
@@ -254,3 +250,44 @@ bool data_is_one_string(struct data d)
 
        return true;
 }
+
+struct data data_insert_data(struct data d, struct marker *m, struct data old)
+{
+       unsigned int offset = m->offset;
+       struct marker *next = m->next;
+       struct marker *marker;
+       struct data new_data;
+       char *ref;
+
+       new_data = data_insert_at_marker(d, m, old.val, old.len);
+
+       /* Copy all markers from old value */
+       marker = old.markers;
+       for_each_marker(marker) {
+               ref = NULL;
+
+               if (marker->ref)
+                       ref = xstrdup(marker->ref);
+
+               m->next = alloc_marker(marker->offset + offset, marker->type,
+                                      ref);
+               m = m->next;
+       }
+       m->next = next;
+
+       return new_data;
+}
+
+struct marker *alloc_marker(unsigned int offset, enum markertype type,
+                           char *ref)
+{
+       struct marker *m;
+
+       m = xmalloc(sizeof(*m));
+       m->offset = offset;
+       m->type = type;
+       m->ref = ref;
+       m->next = NULL;
+
+       return m;
+}
index de60a70b6bdbcb5ae4336ea4171ad6f645e91b36..15d585c8079802d3ab6b00b28bb0aa7bfdb386e9 100644 (file)
@@ -151,6 +151,21 @@ static void PRINTF(1, 2) lexical_error(const char *fmt, ...);
                        return DT_LABEL;
                }
 
+<V1>{LABEL}    {
+                       /* Missed includes or macro definitions while
+                        * preprocessing can lead to unexpected identifiers in
+                        * the input. Report a slightly more informative error
+                        * in this case */
+
+                       lexical_error("Unexpected '%s'", yytext);
+
+                       /* Treat it as a literal which often generates further
+                        * useful error messages */
+
+                       yylval.integer = 0;
+                       return DT_LITERAL;
+               }
+
 <V1>([0-9]+|0[xX][0-9a-fA-F]+)(U|L|UL|LL|ULL)? {
                        char *e;
                        DPRINT("Integer Literal: '%s'\n", yytext);
index 0655c2e2c3624e7b91dcfb7c2ff44f7b576a0f99..b3445b7d6473b1a13499ddd176f47cf108ed8c3c 100644 (file)
@@ -15,7 +15,7 @@ int quiet;            /* Level of quietness */
 unsigned int reservenum;/* Number of memory reservation slots */
 int minsize;           /* Minimum blob size */
 int padsize;           /* Additional padding to blob */
-int alignsize;         /* Additional padding to blob accroding to the alignsize */
+int alignsize;         /* Additional padding to blob according to the alignsize */
 int phandle_format = PHANDLE_EPAPR;    /* Use linux,phandle or phandle properties */
 int generate_symbols;  /* enable symbols & fixup support */
 int generate_fixups;           /* suppress generation of fixups on symbol support */
@@ -289,7 +289,9 @@ int main(int argc, char *argv[])
                if (!depfile)
                        die("Couldn't open dependency file %s: %s\n", depname,
                            strerror(errno));
-               fprintf(depfile, "%s:", outname);
+
+               fprint_path_escaped(depfile, outname);
+               fputc(':', depfile);
        }
 
        if (inform == NULL)
index 4c4aaca1fc417c9d93e904e64b2c40216ee1b093..3a220b9afc99f92ea57d50d348eb0872bc779818 100644 (file)
@@ -38,7 +38,7 @@ extern int quiet;             /* Level of quietness */
 extern unsigned int reservenum;        /* Number of memory reservation slots */
 extern int minsize;            /* Minimum blob size */
 extern int padsize;            /* Additional padding to blob */
-extern int alignsize;          /* Additional padding to blob accroding to the alignsize */
+extern int alignsize;          /* Additional padding to blob according to the alignsize */
 extern int phandle_format;     /* Use linux,phandle or phandle properties */
 extern int generate_symbols;   /* generate symbols for nodes with labels */
 extern int generate_fixups;    /* generate fixups */
@@ -182,7 +182,10 @@ struct data data_append_addr(struct data d, uint64_t addr);
 struct data data_append_byte(struct data d, uint8_t byte);
 struct data data_append_zeroes(struct data d, int len);
 struct data data_append_align(struct data d, int align);
+struct data data_insert_data(struct data d, struct marker *m, struct data old);
 
+struct marker *alloc_marker(unsigned int offset, enum markertype type,
+                           char *ref);
 struct data data_add_marker(struct data d, enum markertype type, char *ref);
 
 bool data_is_one_string(struct data d);
index 699b4f61650231c7e35397d6d14005f8ad2fe062..ee1eb8f3ad28b14762aca9ab5c8a4e36aac967d8 100644 (file)
@@ -46,6 +46,7 @@ static void *apply_one(char *base, const char *overlay, size_t *buf_len,
        char *tmp = NULL;
        char *tmpo;
        int ret;
+       bool has_symbols;
 
        /*
         * We take copies first, because a failed apply can trash
@@ -62,6 +63,8 @@ static void *apply_one(char *base, const char *overlay, size_t *buf_len,
                                fdt_strerror(ret));
                        goto fail;
                }
+               ret = fdt_path_offset(tmp, "/__symbols__");
+               has_symbols = ret >= 0;
 
                memcpy(tmpo, overlay, fdt_totalsize(overlay));
 
@@ -74,6 +77,11 @@ static void *apply_one(char *base, const char *overlay, size_t *buf_len,
        if (ret) {
                fprintf(stderr, "\nFailed to apply '%s': %s\n",
                        name, fdt_strerror(ret));
+               if (!has_symbols) {
+                       fprintf(stderr,
+                               "base blob does not have a '/__symbols__' node, "
+                               "make sure you have compiled the base blob with '-@' option\n");
+               }
                goto fail;
        }
 
index 1bcd8089c5b98b1e4aa0e36fc0ff69473568798c..30e6de2044b2c4368d9dc24cf1039ce6500c4664 100644 (file)
@@ -503,7 +503,7 @@ void dt_to_asm(FILE *f, struct dt_info *dti, int version)
         * Reserve map entries.
         * Align the reserve map to a doubleword boundary.
         * Each entry is an (address, size) pair of u64 values.
-        * Always supply a zero-sized temination entry.
+        * Always supply a zero-sized termination entry.
         */
        asm_emit_align(f, 8);
        emit_label(f, symprefix, "reserve_map");
index 20c6415b9ced113d9fcce25b69007a6b0f9e68e7..95f644c31f9431eb597b6f683741ff9be375cebf 100644 (file)
@@ -312,14 +312,14 @@ int fdt_next_subnode(const void *fdt, int offset)
        return offset;
 }
 
-const char *fdt_find_string_(const char *strtab, int tabsize, const char *s)
+const char *fdt_find_string_len_(const char *strtab, int tabsize, const char *s,
+                                int slen)
 {
-       int len = strlen(s) + 1;
-       const char *last = strtab + tabsize - len;
+       const char *last = strtab + tabsize - (slen + 1);
        const char *p;
 
        for (p = strtab; p <= last; p++)
-               if (memcmp(p, s, len) == 0)
+               if (memcmp(p, s, slen) == 0 && p[slen] == '\0')
                        return p;
        return NULL;
 }
index 0c91aa7f67b5b7d75d94cef2c61e8f7ec2c973c0..a07abfcc71089d176dd576397a514db04da11d52 100644 (file)
@@ -7,7 +7,7 @@
  * Copyright 2012 Kim Phillips, Freescale Semiconductor.
  */
 
-#ifndef __ASSEMBLY__
+#ifndef __ASSEMBLER__
 
 struct fdt_header {
        fdt32_t magic;                   /* magic word FDT_MAGIC */
@@ -45,7 +45,7 @@ struct fdt_property {
        char data[];
 };
 
-#endif /* !__ASSEMBLY */
+#endif /* !__ASSEMBLER__ */
 
 #define FDT_MAGIC      0xd00dfeed      /* 4: version, 4: total size */
 #define FDT_TAGSIZE    sizeof(fdt32_t)
index 28b667ffc490e5a24a2b116714eb218d8d16a995..e6b9eb6439585364ff4e84eecacea7a61bcc67eb 100644 (file)
@@ -307,7 +307,6 @@ static int overlay_update_local_references(void *fdto, uint32_t delta)
 
 /**
  * overlay_fixup_one_phandle - Set an overlay phandle to the base one
- * @fdt: Base Device Tree blob
  * @fdto: Device tree overlay blob
  * @symbols_off: Node offset of the symbols node in the base device tree
  * @path: Path to a node holding a phandle in the overlay
@@ -328,8 +327,7 @@ static int overlay_update_local_references(void *fdto, uint32_t delta)
  *      0 on success
  *      Negative error code on failure
  */
-static int overlay_fixup_one_phandle(void *fdt, void *fdto,
-                                    int symbols_off,
+static int overlay_fixup_one_phandle(void *fdto, int symbols_off,
                                     const char *path, uint32_t path_len,
                                     const char *name, uint32_t name_len,
                                     int poffset, uint32_t phandle)
@@ -351,7 +349,7 @@ static int overlay_fixup_one_phandle(void *fdt, void *fdto,
                                                   name, name_len, poffset,
                                                   &phandle_prop,
                                                   sizeof(phandle_prop));
-};
+}
 
 /**
  * overlay_fixup_phandle - Set an overlay phandle to the base one
@@ -443,7 +441,7 @@ static int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off,
                if ((*endptr != '\0') || (endptr <= (sep + 1)))
                        return -FDT_ERR_BADOVERLAY;
 
-               ret = overlay_fixup_one_phandle(fdt, fdto, symbols_off,
+               ret = overlay_fixup_one_phandle(fdto, symbols_off,
                                                path, path_len, name, name_len,
                                                poffset, phandle);
                if (ret)
index 3621d3651d3f4bd82b7af66c60d023e3139add03..7475cafce071307796d7944ff8278aa5597d0812 100644 (file)
@@ -124,31 +124,33 @@ static int fdt_splice_string_(void *fdt, int newlen)
  *     allocated. Ignored if can_assume(NO_ROLLBACK)
  * @return offset of string in the string table (whether found or added)
  */
-static int fdt_find_add_string_(void *fdt, const char *s, int *allocated)
+static int fdt_find_add_string_(void *fdt, const char *s, int slen,
+                               int *allocated)
 {
        char *strtab = (char *)fdt + fdt_off_dt_strings(fdt);
        const char *p;
        char *new;
-       int len = strlen(s) + 1;
        int err;
 
        if (!can_assume(NO_ROLLBACK))
                *allocated = 0;
 
-       p = fdt_find_string_(strtab, fdt_size_dt_strings(fdt), s);
+       p = fdt_find_string_len_(strtab, fdt_size_dt_strings(fdt), s, slen);
        if (p)
                /* found it */
                return (p - strtab);
 
        new = strtab + fdt_size_dt_strings(fdt);
-       err = fdt_splice_string_(fdt, len);
+       err = fdt_splice_string_(fdt, slen + 1);
        if (err)
                return err;
 
        if (!can_assume(NO_ROLLBACK))
                *allocated = 1;
 
-       memcpy(new, s, len);
+       memcpy(new, s, slen);
+       new[slen] = '\0';
+
        return (new - strtab);
 }
 
@@ -181,13 +183,15 @@ int fdt_del_mem_rsv(void *fdt, int n)
        return fdt_splice_mem_rsv_(fdt, re, 1, 0);
 }
 
-static int fdt_resize_property_(void *fdt, int nodeoffset, const char *name,
+static int fdt_resize_property_(void *fdt, int nodeoffset,
+                               const char *name, int namelen,
                                int len, struct fdt_property **prop)
 {
        int oldlen;
        int err;
 
-       *prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen);
+       *prop = fdt_get_property_namelen_w(fdt, nodeoffset, name, namelen,
+                                          &oldlen);
        if (!*prop)
                return oldlen;
 
@@ -200,7 +204,7 @@ static int fdt_resize_property_(void *fdt, int nodeoffset, const char *name,
 }
 
 static int fdt_add_property_(void *fdt, int nodeoffset, const char *name,
-                            int len, struct fdt_property **prop)
+                            int namelen, int len, struct fdt_property **prop)
 {
        int proplen;
        int nextoffset;
@@ -211,7 +215,7 @@ static int fdt_add_property_(void *fdt, int nodeoffset, const char *name,
        if ((nextoffset = fdt_check_node_offset_(fdt, nodeoffset)) < 0)
                return nextoffset;
 
-       namestroff = fdt_find_add_string_(fdt, name, &allocated);
+       namestroff = fdt_find_add_string_(fdt, name, namelen, &allocated);
        if (namestroff < 0)
                return namestroff;
 
@@ -255,17 +259,18 @@ int fdt_set_name(void *fdt, int nodeoffset, const char *name)
        return 0;
 }
 
-int fdt_setprop_placeholder(void *fdt, int nodeoffset, const char *name,
-                           int len, void **prop_data)
+int fdt_setprop_placeholder_namelen(void *fdt, int nodeoffset, const char *name,
+                                   int namelen, int len, void **prop_data)
 {
        struct fdt_property *prop;
        int err;
 
        FDT_RW_PROBE(fdt);
 
-       err = fdt_resize_property_(fdt, nodeoffset, name, len, &prop);
+       err = fdt_resize_property_(fdt, nodeoffset, name, namelen, len, &prop);
        if (err == -FDT_ERR_NOTFOUND)
-               err = fdt_add_property_(fdt, nodeoffset, name, len, &prop);
+               err = fdt_add_property_(fdt, nodeoffset, name, namelen, len,
+                                       &prop);
        if (err)
                return err;
 
@@ -273,13 +278,14 @@ int fdt_setprop_placeholder(void *fdt, int nodeoffset, const char *name,
        return 0;
 }
 
-int fdt_setprop(void *fdt, int nodeoffset, const char *name,
-               const void *val, int len)
+int fdt_setprop_namelen(void *fdt, int nodeoffset, const char *name,
+                       int namelen, const void *val, int len)
 {
        void *prop_data;
        int err;
 
-       err = fdt_setprop_placeholder(fdt, nodeoffset, name, len, &prop_data);
+       err = fdt_setprop_placeholder_namelen(fdt, nodeoffset, name, namelen,
+                                             len, &prop_data);
        if (err)
                return err;
 
@@ -307,7 +313,8 @@ int fdt_appendprop(void *fdt, int nodeoffset, const char *name,
                prop->len = cpu_to_fdt32(newlen);
                memcpy(prop->data + oldlen, val, len);
        } else {
-               err = fdt_add_property_(fdt, nodeoffset, name, len, &prop);
+               err = fdt_add_property_(fdt, nodeoffset, name, strlen(name),
+                                       len, &prop);
                if (err)
                        return err;
                memcpy(prop->data, val, len);
index 2d409d8e829b3b052a14ab36cab9037935f1c65f..914bf90785ab30b6fe03047126918039b5fa2a70 100644 (file)
@@ -14,7 +14,7 @@ extern "C" {
 #endif
 
 #define FDT_FIRST_SUPPORTED_VERSION    0x02
-#define FDT_LAST_COMPATIBLE_VERSION 0x10
+#define FDT_LAST_COMPATIBLE_VERSION    0x10
 #define FDT_LAST_SUPPORTED_VERSION     0x11
 
 /* Error codes: informative error codes */
@@ -263,16 +263,16 @@ int fdt_next_subnode(const void *fdt, int offset);
                struct fdt_header *fdth = (struct fdt_header *)fdt; \
                fdth->name = cpu_to_fdt32(val); \
        }
-fdt_set_hdr_(magic);
-fdt_set_hdr_(totalsize);
-fdt_set_hdr_(off_dt_struct);
-fdt_set_hdr_(off_dt_strings);
-fdt_set_hdr_(off_mem_rsvmap);
-fdt_set_hdr_(version);
-fdt_set_hdr_(last_comp_version);
-fdt_set_hdr_(boot_cpuid_phys);
-fdt_set_hdr_(size_dt_strings);
-fdt_set_hdr_(size_dt_struct);
+fdt_set_hdr_(magic)
+fdt_set_hdr_(totalsize)
+fdt_set_hdr_(off_dt_struct)
+fdt_set_hdr_(off_dt_strings)
+fdt_set_hdr_(off_mem_rsvmap)
+fdt_set_hdr_(version)
+fdt_set_hdr_(last_comp_version)
+fdt_set_hdr_(boot_cpuid_phys)
+fdt_set_hdr_(size_dt_strings)
+fdt_set_hdr_(size_dt_struct)
 #undef fdt_set_hdr_
 
 /**
@@ -285,7 +285,7 @@ size_t fdt_header_size(const void *fdt);
 
 /**
  * fdt_header_size_ - internal function to get header size from a version number
- * @version: devicetree version number
+ * @version: device tree version number
  *
  * Return: size of DTB header in bytes
  */
@@ -554,7 +554,7 @@ int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen);
  *     -FDT_ERR_BADPATH, given path does not begin with '/' and the first
  *             component is not a valid alias
  *     -FDT_ERR_NOTFOUND, if the requested node does not exist
- *      -FDT_ERR_BADMAGIC,
+ *     -FDT_ERR_BADMAGIC,
  *     -FDT_ERR_BADVERSION,
  *     -FDT_ERR_BADSTATE,
  *     -FDT_ERR_BADSTRUCTURE,
@@ -599,7 +599,7 @@ const char *fdt_get_name(const void *fdt, int nodeoffset, int *lenp);
  *     structure block offset of the property (>=0), on success
  *     -FDT_ERR_NOTFOUND, if the requested node has no properties
  *     -FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_BEGIN_NODE tag
- *      -FDT_ERR_BADMAGIC,
+ *     -FDT_ERR_BADMAGIC,
  *     -FDT_ERR_BADVERSION,
  *     -FDT_ERR_BADSTATE,
  *     -FDT_ERR_BADSTRUCTURE,
@@ -620,7 +620,7 @@ int fdt_first_property_offset(const void *fdt, int nodeoffset);
  *     structure block offset of the next property (>=0), on success
  *     -FDT_ERR_NOTFOUND, if the given property is the last in its node
  *     -FDT_ERR_BADOFFSET, if nodeoffset did not point to an FDT_PROP tag
- *      -FDT_ERR_BADMAGIC,
+ *     -FDT_ERR_BADMAGIC,
  *     -FDT_ERR_BADVERSION,
  *     -FDT_ERR_BADSTATE,
  *     -FDT_ERR_BADSTRUCTURE,
@@ -712,6 +712,13 @@ const struct fdt_property *fdt_get_property_namelen(const void *fdt,
                                                    int nodeoffset,
                                                    const char *name,
                                                    int namelen, int *lenp);
+static inline struct fdt_property *
+fdt_get_property_namelen_w(void *fdt, int nodeoffset, const char *name,
+                          int namelen, int *lenp)
+{
+       return (struct fdt_property *)(uintptr_t)fdt_get_property_namelen(
+               fdt, nodeoffset, name, namelen, lenp);
+}
 #endif
 
 /**
@@ -764,7 +771,7 @@ static inline struct fdt_property *fdt_get_property_w(void *fdt, int nodeoffset,
  * to within the device blob itself, not a copy of the value).  If
  * lenp is non-NULL, the length of the property value is also
  * returned, in the integer pointed to by lenp.  If namep is non-NULL,
- * the property's namne will also be returned in the char * pointed to
+ * the property's name will also be returned in the char * pointed to
  * by namep (this will be a pointer to within the device tree's string
  * block, not a new copy of the name).
  *
@@ -772,7 +779,7 @@ static inline struct fdt_property *fdt_get_property_w(void *fdt, int nodeoffset,
  *     pointer to the property's value
  *             if lenp is non-NULL, *lenp contains the length of the property
  *             value (>=0)
- *             if namep is non-NULL *namep contiains a pointer to the property
+ *             if namep is non-NULL *namep contains a pointer to the property
  *             name.
  *     NULL, on error
  *             if lenp is non-NULL, *lenp contains an error code (<0):
@@ -866,7 +873,7 @@ uint32_t fdt_get_phandle(const void *fdt, int nodeoffset);
 /**
  * fdt_get_alias_namelen - get alias based on substring
  * @fdt: pointer to the device tree blob
- * @name: name of the alias th look up
+ * @name: name of the alias to look up
  * @namelen: number of characters of name to consider
  *
  * Identical to fdt_get_alias(), but only examine the first @namelen
@@ -883,7 +890,7 @@ const char *fdt_get_alias_namelen(const void *fdt,
 /**
  * fdt_get_alias - retrieve the path referenced by a given alias
  * @fdt: pointer to the device tree blob
- * @name: name of the alias th look up
+ * @name: name of the alias to look up
  *
  * fdt_get_alias() retrieves the value of a given alias.  That is, the
  * value of the property named @name in the node /aliases.
@@ -1259,8 +1266,8 @@ const char *fdt_stringlist_get(const void *fdt, int nodeoffset,
  *
  * returns:
  *     0 <= n < FDT_MAX_NCELLS, on success
- *      2, if the node has no #address-cells property
- *      -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid
+ *     2, if the node has no #address-cells property
+ *     -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid
  *             #address-cells property
  *     -FDT_ERR_BADMAGIC,
  *     -FDT_ERR_BADVERSION,
@@ -1280,8 +1287,8 @@ int fdt_address_cells(const void *fdt, int nodeoffset);
  *
  * returns:
  *     0 <= n < FDT_MAX_NCELLS, on success
- *      1, if the node has no #size-cells property
- *      -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid
+ *     1, if the node has no #size-cells property
+ *     -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid
  *             #size-cells property
  *     -FDT_ERR_BADMAGIC,
  *     -FDT_ERR_BADVERSION,
@@ -1562,7 +1569,7 @@ static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val)
  * @fdt: pointer to the device tree blob
  * @name: name of property to add
  * @len: length of property value in bytes
- * @valp: returns a pointer to where where the value should be placed
+ * @valp: returns a pointer to where the value should be placed
  *
  * returns:
  *     0, on success
@@ -1659,6 +1666,38 @@ int fdt_del_mem_rsv(void *fdt, int n);
  */
 int fdt_set_name(void *fdt, int nodeoffset, const char *name);
 
+/**
+ * fdt_setprop_namelen - create or change a property
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose property to change
+ * @name: name of the property to change
+ * @namelen: length of the name
+ * @val: pointer to data to set the property value to
+ * @len: length of the property value
+ *
+ * fdt_setprop_namelen() sets the value of the named property in the given
+ * node to the given value and length, creating the property if it
+ * does not already exist.
+ *
+ * This function may insert or delete data from the blob, and will
+ * therefore change the offsets of some existing nodes.
+ *
+ * returns:
+ *     0, on success
+ *     -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
+ *             contain the new property value
+ *     -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ *     -FDT_ERR_BADLAYOUT,
+ *     -FDT_ERR_BADMAGIC,
+ *     -FDT_ERR_BADVERSION,
+ *     -FDT_ERR_BADSTATE,
+ *     -FDT_ERR_BADSTRUCTURE,
+ *     -FDT_ERR_BADLAYOUT,
+ *     -FDT_ERR_TRUNCATED, standard meanings
+ */
+int fdt_setprop_namelen(void *fdt, int nodeoffset, const char *name,
+                       int namelen, const void *val, int len);
+
 /**
  * fdt_setprop - create or change a property
  * @fdt: pointer to the device tree blob
@@ -1687,8 +1726,44 @@ int fdt_set_name(void *fdt, int nodeoffset, const char *name);
  *     -FDT_ERR_BADLAYOUT,
  *     -FDT_ERR_TRUNCATED, standard meanings
  */
-int fdt_setprop(void *fdt, int nodeoffset, const char *name,
-               const void *val, int len);
+static inline int fdt_setprop(void *fdt, int nodeoffset, const char *name,
+                             const void *val, int len)
+{
+       return fdt_setprop_namelen(fdt, nodeoffset, name, strlen(name), val,
+                                  len);
+}
+
+/**
+ * fdt_setprop_placeholder_namelen - allocate space for a property
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose property to change
+ * @name: name of the property to change
+ * @namelen: length of the name
+ * @len: length of the property value
+ * @prop_data: return pointer to property data
+ *
+ * fdt_setprop_placeholder_namelen() allocates the named property in the given node.
+ * If the property exists it is resized. In either case a pointer to the
+ * property data is returned.
+ *
+ * This function may insert or delete data from the blob, and will
+ * therefore change the offsets of some existing nodes.
+ *
+ * returns:
+ *     0, on success
+ *     -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
+ *             contain the new property value
+ *     -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ *     -FDT_ERR_BADLAYOUT,
+ *     -FDT_ERR_BADMAGIC,
+ *     -FDT_ERR_BADVERSION,
+ *     -FDT_ERR_BADSTATE,
+ *     -FDT_ERR_BADSTRUCTURE,
+ *     -FDT_ERR_BADLAYOUT,
+ *     -FDT_ERR_TRUNCATED, standard meanings
+ */
+int fdt_setprop_placeholder_namelen(void *fdt, int nodeoffset, const char *name,
+                                   int namelen, int len, void **prop_data);
 
 /**
  * fdt_setprop_placeholder - allocate space for a property
@@ -1698,7 +1773,7 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
  * @len: length of the property value
  * @prop_data: return pointer to property data
  *
- * fdt_setprop_placeholer() allocates the named property in the given node.
+ * fdt_setprop_placeholder() allocates the named property in the given node.
  * If the property exists it is resized. In either case a pointer to the
  * property data is returned.
  *
@@ -1718,8 +1793,13 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
  *     -FDT_ERR_BADLAYOUT,
  *     -FDT_ERR_TRUNCATED, standard meanings
  */
-int fdt_setprop_placeholder(void *fdt, int nodeoffset, const char *name,
-                           int len, void **prop_data);
+static inline int fdt_setprop_placeholder(void *fdt, int nodeoffset,
+                                         const char *name, int len,
+                                         void **prop_data)
+{
+       return fdt_setprop_placeholder_namelen(fdt, nodeoffset, name,
+                                              strlen(name), len, prop_data);
+}
 
 /**
  * fdt_setprop_u32 - set a property to a 32-bit integer
@@ -1839,6 +1919,38 @@ static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name,
 #define fdt_setprop_string(fdt, nodeoffset, name, str) \
        fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1)
 
+/**
+ * fdt_setprop_namelen_string - set a property to a string value
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose property to change
+ * @name: name of the property to change
+ * @namelen: number of characters of name to consider
+ * @str: string value for the property
+ *
+ * fdt_setprop_namelen_string() sets the value of the named property in the
+ * given node to the given string value (using the length of the
+ * string to determine the new length of the property), or creates a
+ * new property with that value if it does not already exist.
+ *
+ * This function may insert or delete data from the blob, and will
+ * therefore change the offsets of some existing nodes.
+ *
+ * returns:
+ *     0, on success
+ *     -FDT_ERR_NOSPACE, there is insufficient free space in the blob to
+ *             contain the new property value
+ *     -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ *     -FDT_ERR_BADLAYOUT,
+ *     -FDT_ERR_BADMAGIC,
+ *     -FDT_ERR_BADVERSION,
+ *     -FDT_ERR_BADSTATE,
+ *     -FDT_ERR_BADSTRUCTURE,
+ *     -FDT_ERR_BADLAYOUT,
+ *     -FDT_ERR_TRUNCATED, standard meanings
+ */
+#define fdt_setprop_namelen_string(fdt, nodeoffset, name, namelen, str)    \
+       fdt_setprop_namelen((fdt), (nodeoffset), (name), (namelen), (str), \
+                           strlen(str) + 1)
 
 /**
  * fdt_setprop_empty - set a property to an empty value
@@ -2059,7 +2171,7 @@ int fdt_appendprop_addrrange(void *fdt, int parent, int nodeoffset,
  * @nodeoffset: offset of the node whose property to nop
  * @name: name of the property to nop
  *
- * fdt_del_property() will delete the given property.
+ * fdt_delprop() will delete the given property.
  *
  * This function will delete data from the blob, and will therefore
  * change the offsets of some existing nodes.
@@ -2111,8 +2223,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
  * change the offsets of some existing nodes.
  *
  * returns:
- *     structure block offset of the created nodeequested subnode (>=0), on
- *             success
+ *     structure block offset of the created subnode (>=0), on success
  *     -FDT_ERR_NOTFOUND, if the requested subnode does not exist
  *     -FDT_ERR_BADOFFSET, if parentoffset did not point to an FDT_BEGIN_NODE
  *             tag
@@ -2122,7 +2233,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
  *             blob to contain the new node
  *     -FDT_ERR_NOSPACE
  *     -FDT_ERR_BADLAYOUT
- *      -FDT_ERR_BADMAGIC,
+ *     -FDT_ERR_BADMAGIC,
  *     -FDT_ERR_BADVERSION,
  *     -FDT_ERR_BADSTATE,
  *     -FDT_ERR_BADSTRUCTURE,
@@ -2167,7 +2278,7 @@ int fdt_del_node(void *fdt, int nodeoffset);
  * returns:
  *     0, on success
  *     -FDT_ERR_NOSPACE, there's not enough space in the base device tree
- *     -FDT_ERR_NOTFOUND, the overlay points to some inexistant nodes or
+ *     -FDT_ERR_NOTFOUND, the overlay points to some nonexistent nodes or
  *             properties in the base DT
  *     -FDT_ERR_BADPHANDLE,
  *     -FDT_ERR_BADOVERLAY,
index 16bda1906a7b335519b9f748d1be6110de551e79..b60b5456f596b8ad5d9daf9db4b182422f05549d 100644 (file)
@@ -20,7 +20,15 @@ int32_t fdt_ro_probe_(const void *fdt);
 
 int fdt_check_node_offset_(const void *fdt, int offset);
 int fdt_check_prop_offset_(const void *fdt, int offset);
-const char *fdt_find_string_(const char *strtab, int tabsize, const char *s);
+
+const char *fdt_find_string_len_(const char *strtab, int tabsize, const char *s,
+                                int s_len);
+static inline const char *fdt_find_string_(const char *strtab, int tabsize,
+                                          const char *s)
+{
+       return fdt_find_string_len_(strtab, tabsize, s, strlen(s));
+}
+
 int fdt_node_end_offset_(void *fdt, int nodeoffset);
 
 static inline const void *fdt_offset_ptr_(const void *fdt, int offset)
@@ -47,8 +55,8 @@ static inline struct fdt_reserve_entry *fdt_mem_rsv_w_(void *fdt, int n)
 }
 
 /*
- * Internal helpers to access tructural elements of the device tree
- * blob (rather than for exaple reading integers from within property
+ * Internal helpers to access structural elements of the device tree
+ * blob (rather than for example reading integers from within property
  * values).  We assume that we are either given a naturally aligned
  * address for the platform or if we are not, we are on a platform
  * where unaligned memory reads will be handled in a graceful manner.
index 49f723002f855764452b30b5a979b6096730a33b..d51d05830b181476ddbab878ef8b556230b58e2b 100644 (file)
@@ -174,7 +174,7 @@ struct node *merge_nodes(struct node *old_node, struct node *new_node)
 
                                old_prop->val = new_prop->val;
                                old_prop->deleted = 0;
-                               free(old_prop->srcpos);
+                               srcpos_free(old_prop->srcpos);
                                old_prop->srcpos = new_prop->srcpos;
                                free(new_prop);
                                new_prop = NULL;
@@ -504,7 +504,7 @@ struct node *get_subnode(struct node *node, const char *nodename)
        struct node *child;
 
        for_each_child(node, child)
-               if (streq(child->name, nodename))
+               if (streq(child->name, nodename) && !child->deleted)
                        return child;
 
        return NULL;
@@ -1014,9 +1014,7 @@ static void add_local_fixup_entry(struct dt_info *dti,
        /* walk the path components creating nodes if they don't exist */
        for (wn = lfn, i = 1; i < depth; i++, wn = nwn) {
                /* if no node exists, create it */
-               nwn = get_subnode(wn, compp[i]);
-               if (!nwn)
-                       nwn = build_and_name_child_node(wn, compp[i]);
+               nwn = build_root_node(wn, compp[i]);
        }
 
        free(compp);
@@ -1058,16 +1056,29 @@ void generate_label_tree(struct dt_info *dti, const char *name, bool allocph)
 
 void generate_fixups_tree(struct dt_info *dti, const char *name)
 {
+       struct node *n = get_subnode(dti->dt, name);
+
+       /* Start with an empty __fixups__ node to not get duplicates */
+       if (n)
+               n->deleted = true;
+
        if (!any_fixup_tree(dti, dti->dt))
                return;
-       generate_fixups_tree_internal(dti, build_root_node(dti->dt, name),
+       generate_fixups_tree_internal(dti,
+                                     build_and_name_child_node(dti->dt, name),
                                      dti->dt);
 }
 
 void generate_local_fixups_tree(struct dt_info *dti, const char *name)
 {
+       struct node *n = get_subnode(dti->dt, name);
+
+       /* Start with an empty __local_fixups__ node to not get duplicates */
+       if (n)
+               n->deleted = true;
        if (!any_local_fixup_tree(dti, dti->dt))
                return;
-       generate_local_fixups_tree_internal(dti, build_root_node(dti->dt, name),
+       generate_local_fixups_tree_internal(dti,
+                                           build_and_name_child_node(dti->dt, name),
                                            dti->dt);
 }
index 8e4d18a90b472eb7a68cce6fd5637463415ec4b0..5bb57bf6856c6ff6b8eb993aff5d216c63bf5ecb 100644 (file)
@@ -160,8 +160,10 @@ FILE *srcfile_relative_open(const char *fname, char **fullnamep)
                            strerror(errno));
        }
 
-       if (depfile)
-               fprintf(depfile, " %s", fullname);
+       if (depfile) {
+               fputc(' ', depfile);
+               fprint_path_escaped(depfile, fullname);
+       }
 
        if (fullnamep)
                *fullnamep = fullname;
@@ -285,6 +287,17 @@ struct srcpos *srcpos_extend(struct srcpos *pos, struct srcpos *newtail)
        return pos;
 }
 
+void srcpos_free(struct srcpos *pos)
+{
+       struct srcpos *p_next;
+
+       while (pos) {
+               p_next = pos->next;
+               free(pos);
+               pos = p_next;
+       }
+}
+
 char *
 srcpos_string(struct srcpos *pos)
 {
index 4318d7ad34d91d2ada1a5d7f92d2c84148fec366..4d60b50e31197c2da6a7fa8851c5e5a6717d78a6 100644 (file)
@@ -88,6 +88,7 @@ extern void srcpos_update(struct srcpos *pos, const char *text, int len);
 extern struct srcpos *srcpos_copy(struct srcpos *pos);
 extern struct srcpos *srcpos_extend(struct srcpos *new_srcpos,
                                    struct srcpos *old_srcpos);
+extern void srcpos_free(struct srcpos *pos);
 extern char *srcpos_string(struct srcpos *pos);
 extern char *srcpos_string_first(struct srcpos *pos, int level);
 extern char *srcpos_string_last(struct srcpos *pos, int level);
index ae15839ba6a588b25037a5f109c2bfe427605a0b..d25f01fc693793a108f66c800683e726b436c6b1 100644 (file)
@@ -139,26 +139,48 @@ static const char *delim_end[] = {
        [TYPE_STRING] = "",
 };
 
+/*
+ * The invariants in the marker list are:
+ *  - offsets are non-strictly monotonically increasing
+ *  - for a single offset there is at most one type marker
+ *  - for a single offset that has both a type marker and non-type markers, the
+ *    type marker appears before the others.
+ */
+static struct marker **add_marker(struct marker **mi,
+                                 enum markertype type, unsigned int offset, char *ref)
+{
+       struct marker *nm;
+
+       while (*mi && (*mi)->offset < offset)
+               mi = &(*mi)->next;
+
+       if (*mi && (*mi)->offset == offset && is_type_marker((*mi)->type)) {
+               if (is_type_marker(type))
+                       return mi;
+               mi = &(*mi)->next;
+       }
+
+       if (*mi && (*mi)->offset == offset && type == (*mi)->type)
+               return mi;
+
+       nm = xmalloc(sizeof(*nm));
+       nm->type = type;
+       nm->offset = offset;
+       nm->ref = ref;
+       nm->next = *mi;
+       *mi = nm;
+
+       return &nm->next;
+}
+
 static void add_string_markers(struct property *prop)
 {
        int l, len = prop->val.len;
        const char *p = prop->val.val;
+       struct marker **mi = &prop->val.markers;
 
-       for (l = strlen(p) + 1; l < len; l += strlen(p + l) + 1) {
-               struct marker *m, **nextp;
-
-               m = xmalloc(sizeof(*m));
-               m->offset = l;
-               m->type = TYPE_STRING;
-               m->ref = NULL;
-               m->next = NULL;
-
-               /* Find the end of the markerlist */
-               nextp = &prop->val.markers;
-               while (*nextp)
-                       nextp = &((*nextp)->next);
-               *nextp = m;
-       }
+       for (l = strlen(p) + 1; l < len; l += strlen(p + l) + 1)
+               mi = add_marker(mi, TYPE_STRING, l, NULL);
 }
 
 static enum markertype guess_value_type(struct property *prop)
index 507f0120cd13ebe9a16f449ec14b8758e3b61fb0..412592320265a333ea6a50d07d2ccdd072b73885 100644 (file)
 #include "util.h"
 #include "version_gen.h"
 
+void fprint_path_escaped(FILE *fp, const char *path)
+{
+       const char *p = path;
+
+       while (*p) {
+               if (*p == ' ') {
+                       fputc('\\', fp);
+                       fputc(' ', fp);
+               } else {
+                       fputc(*p, fp);
+               }
+
+               p++;
+       }
+}
+
 char *xstrdup(const char *s)
 {
        int len = strlen(s) + 1;
index b448cd79efd3d00d42ef34502b5c0b98e21fbde1..800f2e2c55b150d3c30101d1e1f1daaa0e4e3264 100644 (file)
@@ -42,6 +42,11 @@ static inline void NORETURN PRINTF(1, 2) die(const char *str, ...)
        exit(1);
 }
 
+/**
+ * Writes path to fp, escaping spaces with a backslash.
+ */
+void fprint_path_escaped(FILE *fp, const char *path);
+
 static inline void *xmalloc(size_t len)
 {
        void *new = malloc(len);
index bf81ce593685ced4c580b364ae277bb42006f832..226c48bf75dc03355540d60391159aef394ffe5d 100644 (file)
@@ -1 +1 @@
-#define DTC_VERSION "DTC 1.7.0-gbcd02b52"
+#define DTC_VERSION "DTC 1.7.2-g52f07dcc"