]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
scripts/dtc: Update to upstream version v1.4.4-50-gfe50bd1ecc1d
authorTom Rini <trini@konsulko.com>
Sat, 23 Sep 2017 21:31:59 +0000 (17:31 -0400)
committerTom Rini <trini@konsulko.com>
Sat, 23 Sep 2017 21:33:10 +0000 (17:33 -0400)
This adds the following commits from upstream:

fe50bd1ecc1d fdtget: Split out cell list display into a new function
62d812308d11 README: Add a note about test_tree1.dts
5bed86aee9e8 pylibfdt: Add support for fdt_subnode_offset()
46f31b65b3b3 pylibfdt: Add support for fdt_node_offset_by_phandle()
a3ae43723687 pylibfdt: Add support for fdt_parent_offset()
a198af80344c pylibfdt: Add support for fdt_get_phandle()
b9eba92ea50f tests: Return a failure code when any tests fail
155faf6cc209 pylibfdt: Use local pylibfdt module
50e5cd07f325 pylibfdt: Add a test for use of uint32_t
ab78860f09f5 pylibfdt: Add stdint include to fix uint32_t
36f511fb1113 tests: Add stacked overlay tests on fdtoverlay
1bb00655d3e5 fdt: Allow stacked overlays phandle references
a33c2247ac8d Introduce fdt_setprop_placeholder() method
0016f8c2aa32 dtc: change default phandles to ePAPR style instead of both
e3b9a9588a35 tests: fdtoverlay unit test
42409146f2db fdtoverlay: A tool that applies overlays
aae22722fc8d manual: Document missing options
13ce6e1c2fc4 dtc: fix sprintf() format string error, again
d990b8013889 Makefile: Fix build on MSYS2 and Cygwin
51f56dedf8ea Clean up shared library compile/link options
21a2bc896e3d Suppress expected error message in fdtdump test
2a42b14d0d03 dtc: check.c fix compile error
a10cb3c818d3 Fix get_node_by_path string equality check
548aea2c436a fdtdump: Discourage use of fdtdump
c2258841a785 fdtdump: Fix over-zealous version check
9067ee4be0e6 Fix a few whitespace and style nits
e56f2b07be38 pylibfdt: Use setup.py to build the swig file
896f1c133265 pylibfdt: Use Makefile constructs to implement NO_PYTHON
90db6d9989ca pylibfdt: Allow setup.py to operate stand-alone
e20d9658cd8f Add Coverity Scan support
b04a2cf08862 pylibfdt: Fix code style in setup.py
1c5170d3a466 pylibfdt: Rename libfdt.swig to libfdt.i
580a9f6c2880 Add a libfdt function to write a property placeholder
ab15256d8d02 pylibfdt: Use the call function to simplify the Makefile
9f2e3a3a1f19 pylibfdt: Use the correct libfdt version in the module
e91c652af215 pylibfdt: Enable installation of Python module
8a892fd85d94 pylibfdt: Allow building to be disabled
741cdff85d3e .travis.yml: Add builds with and without Python library prerequisites
14c4171f4f9a pylibfdt: Use package_dir to set the package directory
89a5062ab231 pylibfdt: Use environment to pass C flags and files
4e0e0d049757 pylibfdt: Allow pkg-config to be supplied in the environment
6afd7d9688f5 Correct typo: s/pylibgfdt/pylibfdt/
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

Signed-off-by: Tom Rini <trini@konsulko.com>
scripts/dtc/checks.c
scripts/dtc/dtc.c
scripts/dtc/dtc.h
scripts/dtc/libfdt/fdt_empty_tree.c
scripts/dtc/libfdt/fdt_ro.c
scripts/dtc/libfdt/fdt_rw.c
scripts/dtc/libfdt/fdt_sw.c
scripts/dtc/libfdt/fdt_wip.c
scripts/dtc/libfdt/libfdt.h
scripts/dtc/livetree.c
scripts/dtc/version_gen.h

index 38f548e582c82f6bba622f47799eccf22820ac74..afabf64337d564bccb1df1819e9b0978971b7d27 100644 (file)
@@ -681,6 +681,229 @@ static void check_ranges_format(struct check *c, struct dt_info *dti,
 }
 WARNING(ranges_format, check_ranges_format, NULL, &addr_size_cells);
 
+static const struct bus_type pci_bus = {
+       .name = "PCI",
+};
+
+static void check_pci_bridge(struct check *c, struct dt_info *dti, struct node *node)
+{
+       struct property *prop;
+       cell_t *cells;
+
+       prop = get_property(node, "device_type");
+       if (!prop || !streq(prop->val.val, "pci"))
+               return;
+
+       node->bus = &pci_bus;
+
+       if (!strneq(node->name, "pci", node->basenamelen) &&
+           !strneq(node->name, "pcie", node->basenamelen))
+               FAIL(c, dti, "Node %s node name is not \"pci\" or \"pcie\"",
+                            node->fullpath);
+
+       prop = get_property(node, "ranges");
+       if (!prop)
+               FAIL(c, dti, "Node %s missing ranges for PCI bridge (or not a bridge)",
+                            node->fullpath);
+
+       if (node_addr_cells(node) != 3)
+               FAIL(c, dti, "Node %s incorrect #address-cells for PCI bridge",
+                            node->fullpath);
+       if (node_size_cells(node) != 2)
+               FAIL(c, dti, "Node %s incorrect #size-cells for PCI bridge",
+                            node->fullpath);
+
+       prop = get_property(node, "bus-range");
+       if (!prop) {
+               FAIL(c, dti, "Node %s missing bus-range for PCI bridge",
+                            node->fullpath);
+               return;
+       }
+       if (prop->val.len != (sizeof(cell_t) * 2)) {
+               FAIL(c, dti, "Node %s bus-range must be 2 cells",
+                            node->fullpath);
+               return;
+       }
+       cells = (cell_t *)prop->val.val;
+       if (fdt32_to_cpu(cells[0]) > fdt32_to_cpu(cells[1]))
+               FAIL(c, dti, "Node %s bus-range 1st cell must be less than or equal to 2nd cell",
+                            node->fullpath);
+       if (fdt32_to_cpu(cells[1]) > 0xff)
+               FAIL(c, dti, "Node %s bus-range maximum bus number must be less than 256",
+                            node->fullpath);
+}
+WARNING(pci_bridge, check_pci_bridge, NULL,
+       &device_type_is_string, &addr_size_cells);
+
+static void check_pci_device_bus_num(struct check *c, struct dt_info *dti, struct node *node)
+{
+       struct property *prop;
+       unsigned int bus_num, min_bus, max_bus;
+       cell_t *cells;
+
+       if (!node->parent || (node->parent->bus != &pci_bus))
+               return;
+
+       prop = get_property(node, "reg");
+       if (!prop)
+               return;
+
+       cells = (cell_t *)prop->val.val;
+       bus_num = (fdt32_to_cpu(cells[0]) & 0x00ff0000) >> 16;
+
+       prop = get_property(node->parent, "bus-range");
+       if (!prop) {
+               min_bus = max_bus = 0;
+       } else {
+               cells = (cell_t *)prop->val.val;
+               min_bus = fdt32_to_cpu(cells[0]);
+               max_bus = fdt32_to_cpu(cells[0]);
+       }
+       if ((bus_num < min_bus) || (bus_num > max_bus))
+               FAIL(c, dti, "Node %s PCI bus number %d out of range, expected (%d - %d)",
+                    node->fullpath, bus_num, min_bus, max_bus);
+}
+WARNING(pci_device_bus_num, check_pci_device_bus_num, NULL, &reg_format, &pci_bridge);
+
+static void check_pci_device_reg(struct check *c, struct dt_info *dti, struct node *node)
+{
+       struct property *prop;
+       const char *unitname = get_unitname(node);
+       char unit_addr[5];
+       unsigned int dev, func, reg;
+       cell_t *cells;
+
+       if (!node->parent || (node->parent->bus != &pci_bus))
+               return;
+
+       prop = get_property(node, "reg");
+       if (!prop) {
+               FAIL(c, dti, "Node %s missing PCI reg property", node->fullpath);
+               return;
+       }
+
+       cells = (cell_t *)prop->val.val;
+       if (cells[1] || cells[2])
+               FAIL(c, dti, "Node %s PCI reg config space address cells 2 and 3 must be 0",
+                            node->fullpath);
+
+       reg = fdt32_to_cpu(cells[0]);
+       dev = (reg & 0xf800) >> 11;
+       func = (reg & 0x700) >> 8;
+
+       if (reg & 0xff000000)
+               FAIL(c, dti, "Node %s PCI reg address is not configuration space",
+                            node->fullpath);
+       if (reg & 0x000000ff)
+               FAIL(c, dti, "Node %s PCI reg config space address register number must be 0",
+                            node->fullpath);
+
+       if (func == 0) {
+               snprintf(unit_addr, sizeof(unit_addr), "%x", dev);
+               if (streq(unitname, unit_addr))
+                       return;
+       }
+
+       snprintf(unit_addr, sizeof(unit_addr), "%x,%x", dev, func);
+       if (streq(unitname, unit_addr))
+               return;
+
+       FAIL(c, dti, "Node %s PCI unit address format error, expected \"%s\"",
+            node->fullpath, unit_addr);
+}
+WARNING(pci_device_reg, check_pci_device_reg, NULL, &reg_format, &pci_bridge);
+
+static const struct bus_type simple_bus = {
+       .name = "simple-bus",
+};
+
+static bool node_is_compatible(struct node *node, const char *compat)
+{
+       struct property *prop;
+       const char *str, *end;
+
+       prop = get_property(node, "compatible");
+       if (!prop)
+               return false;
+
+       for (str = prop->val.val, end = str + prop->val.len; str < end;
+            str += strnlen(str, end - str) + 1) {
+               if (strneq(str, compat, end - str))
+                       return true;
+       }
+       return false;
+}
+
+static void check_simple_bus_bridge(struct check *c, struct dt_info *dti, struct node *node)
+{
+       if (node_is_compatible(node, "simple-bus"))
+               node->bus = &simple_bus;
+}
+WARNING(simple_bus_bridge, check_simple_bus_bridge, NULL, &addr_size_cells);
+
+static void check_simple_bus_reg(struct check *c, struct dt_info *dti, struct node *node)
+{
+       struct property *prop;
+       const char *unitname = get_unitname(node);
+       char unit_addr[17];
+       unsigned int size;
+       uint64_t reg = 0;
+       cell_t *cells = NULL;
+
+       if (!node->parent || (node->parent->bus != &simple_bus))
+               return;
+
+       prop = get_property(node, "reg");
+       if (prop)
+               cells = (cell_t *)prop->val.val;
+       else {
+               prop = get_property(node, "ranges");
+               if (prop && prop->val.len)
+                       /* skip of child address */
+                       cells = ((cell_t *)prop->val.val) + node_addr_cells(node);
+       }
+
+       if (!cells) {
+               if (node->parent->parent && !(node->bus == &simple_bus))
+                       FAIL(c, dti, "Node %s missing or empty reg/ranges property", node->fullpath);
+               return;
+       }
+
+       size = node_addr_cells(node->parent);
+       while (size--)
+               reg = (reg << 32) | fdt32_to_cpu(*(cells++));
+
+       snprintf(unit_addr, sizeof(unit_addr), "%"PRIx64, reg);
+       if (!streq(unitname, unit_addr))
+               FAIL(c, dti, "Node %s simple-bus unit address format error, expected \"%s\"",
+                    node->fullpath, unit_addr);
+}
+WARNING(simple_bus_reg, check_simple_bus_reg, NULL, &reg_format, &simple_bus_bridge);
+
+static void check_unit_address_format(struct check *c, struct dt_info *dti,
+                                     struct node *node)
+{
+       const char *unitname = get_unitname(node);
+
+       if (node->parent && node->parent->bus)
+               return;
+
+       if (!unitname[0])
+               return;
+
+       if (!strncmp(unitname, "0x", 2)) {
+               FAIL(c, dti, "Node %s unit name should not have leading \"0x\"",
+                   node->fullpath);
+               /* skip over 0x for next test */
+               unitname += 2;
+       }
+       if (unitname[0] == '0' && isxdigit(unitname[1]))
+               FAIL(c, dti, "Node %s unit name should not have leading 0s",
+                   node->fullpath);
+}
+WARNING(unit_address_format, check_unit_address_format, NULL,
+       &node_name_format, &pci_bridge, &simple_bus_bridge);
+
 /*
  * Style checks
  */
@@ -752,6 +975,14 @@ static struct check *check_table[] = {
        &addr_size_cells, &reg_format, &ranges_format,
 
        &unit_address_vs_reg,
+       &unit_address_format,
+
+       &pci_bridge,
+       &pci_device_reg,
+       &pci_device_bus_num,
+
+       &simple_bus_bridge,
+       &simple_bus_reg,
 
        &avoid_default_addr_size,
        &obsolete_chosen_interrupt_controller,
index f5eed9d72c0241bbe36c90aebe7dd7f60cc430fb..5ed873c72ad1eb803d5ebcde83ba90ca0a6bb07a 100644 (file)
@@ -31,7 +31,7 @@ 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 phandle_format = PHANDLE_BOTH;     /* Use linux,phandle or phandle properties */
+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 */
 int auto_label_aliases;                /* auto generate labels -> aliases */
index 403b79deab888cbbe1bb07515cd98bdfb3e37a6e..409db76c94b7bba3740c4e47415a67e510e60744 100644 (file)
@@ -31,6 +31,7 @@
 #include <ctype.h>
 #include <errno.h>
 #include <unistd.h>
+#include <inttypes.h>
 
 #include <libfdt_env.h>
 #include <fdt.h>
@@ -135,6 +136,10 @@ struct label {
        struct label *next;
 };
 
+struct bus_type {
+       const char *name;
+};
+
 struct property {
        bool deleted;
        char *name;
@@ -161,6 +166,7 @@ struct node {
        int addr_cells, size_cells;
 
        struct label *labels;
+       const struct bus_type *bus;
 };
 
 #define for_each_label_withdel(l0, l) \
index f72d13b1d19c0bce7a27658e18a5f9fe26b2453c..f2ae9b77c285733e50b4b496407471149650d290 100644 (file)
@@ -81,4 +81,3 @@ int fdt_create_empty_tree(void *buf, int bufsize)
 
        return fdt_open_into(buf, buf, bufsize);
 }
-
index 3d00d2eee0e3263bc3b0019abaed66f4e87881fa..08de2cce674d3a62967592e502d8f33297eb3489 100644 (file)
@@ -60,7 +60,7 @@ static int _fdt_nodename_eq(const void *fdt, int offset,
 {
        const char *p = fdt_offset_ptr(fdt, offset + FDT_TAGSIZE, len+1);
 
-       if (! p)
+       if (!p)
                /* short match */
                return 0;
 
@@ -327,7 +327,7 @@ const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
        const struct fdt_property *prop;
 
        prop = fdt_get_property_namelen(fdt, nodeoffset, name, namelen, lenp);
-       if (! prop)
+       if (!prop)
                return NULL;
 
        return prop->data;
index 3fd5847377c9b5be3d1cfc4e9485b25b5cdf6cf9..5c3a2bb0bc6bc3d208ca1bfd30b6c076db811202 100644 (file)
@@ -207,7 +207,7 @@ static int _fdt_resize_property(void *fdt, int nodeoffset, const char *name,
        int err;
 
        *prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen);
-       if (! (*prop))
+       if (!*prop)
                return oldlen;
 
        if ((err = _fdt_splice_struct(fdt, (*prop)->data, FDT_TAGALIGN(oldlen),
@@ -269,8 +269,8 @@ int fdt_set_name(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_placeholder(void *fdt, int nodeoffset, const char *name,
+                           int len, void **prop_data)
 {
        struct fdt_property *prop;
        int err;
@@ -283,8 +283,22 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
        if (err)
                return err;
 
+       *prop_data = prop->data;
+       return 0;
+}
+
+int fdt_setprop(void *fdt, int nodeoffset, const char *name,
+               const void *val, int len)
+{
+       void *prop_data;
+       int err;
+
+       err = fdt_setprop_placeholder(fdt, nodeoffset, name, len, &prop_data);
+       if (err)
+               return err;
+
        if (len)
-               memcpy(prop->data, val, len);
+               memcpy(prop_data, val, len);
        return 0;
 }
 
@@ -323,7 +337,7 @@ int fdt_delprop(void *fdt, int nodeoffset, const char *name)
        FDT_RW_CHECK_HEADER(fdt);
 
        prop = fdt_get_property_w(fdt, nodeoffset, name, &len);
-       if (! prop)
+       if (!prop)
                return len;
 
        proplen = sizeof(*prop) + FDT_TAGALIGN(len);
index 6a804859fd0c189636677b80f1c20c9cff9b30af..2bd15e7aef872c13992cbe6d85e2bd8bb4b08a2e 100644 (file)
@@ -220,7 +220,7 @@ static int _fdt_find_add_string(void *fdt, const char *s)
        return offset;
 }
 
-int fdt_property(void *fdt, const char *name, const void *val, int len)
+int fdt_property_placeholder(void *fdt, const char *name, int len, void **valp)
 {
        struct fdt_property *prop;
        int nameoff;
@@ -238,7 +238,19 @@ int fdt_property(void *fdt, const char *name, const void *val, int len)
        prop->tag = cpu_to_fdt32(FDT_PROP);
        prop->nameoff = cpu_to_fdt32(nameoff);
        prop->len = cpu_to_fdt32(len);
-       memcpy(prop->data, val, len);
+       *valp = prop->data;
+       return 0;
+}
+
+int fdt_property(void *fdt, const char *name, const void *val, int len)
+{
+       void *ptr;
+       int ret;
+
+       ret = fdt_property_placeholder(fdt, name, len, &ptr);
+       if (ret)
+               return ret;
+       memcpy(ptr, val, len);
        return 0;
 }
 
index 6aaab399929c84a4615d98dd458bc17e9c94dea4..5e859198622bd48d60b4f6d59e954c79723e4747 100644 (file)
@@ -82,7 +82,7 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
        int proplen;
 
        propval = fdt_getprop(fdt, nodeoffset, name, &proplen);
-       if (! propval)
+       if (!propval)
                return proplen;
 
        if (proplen != len)
@@ -107,7 +107,7 @@ int fdt_nop_property(void *fdt, int nodeoffset, const char *name)
        int len;
 
        prop = fdt_get_property_w(fdt, nodeoffset, name, &len);
-       if (! prop)
+       if (!prop)
                return len;
 
        _fdt_nop_region(prop, len + sizeof(*prop));
index 9e71bb9e03a75b4900f9976a3c174b19fbadda5a..7f83023ee10947f366e4846bc9ddb78b408dbb36 100644 (file)
 /* Low-level functions (you probably don't need these)                */
 /**********************************************************************/
 
+#ifndef SWIG /* This function is not useful in Python */
 const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int checklen);
+#endif
 static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen)
 {
        return (void *)(uintptr_t)fdt_offset_ptr(fdt, offset, checklen);
@@ -210,7 +212,6 @@ int fdt_next_subnode(const void *fdt, int offset);
 /**********************************************************************/
 /* General functions                                                  */
 /**********************************************************************/
-
 #define fdt_get_header(fdt, field) \
        (fdt32_to_cpu(((const struct fdt_header *)(fdt))->field))
 #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);
  * useful for finding subnodes based on a portion of a larger string,
  * such as a full path.
  */
+#ifndef SWIG /* Not available in Python */
 int fdt_subnode_offset_namelen(const void *fdt, int parentoffset,
                               const char *name, int namelen);
+#endif
 /**
  * fdt_subnode_offset - find a subnode of a given node
  * @fdt: pointer to the device tree blob
@@ -391,7 +394,9 @@ int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name);
  * Identical to fdt_path_offset(), but only consider the first namelen
  * characters of path as the path name.
  */
+#ifndef SWIG /* Not available in Python */
 int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen);
+#endif
 
 /**
  * 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,
  * Identical to fdt_get_property(), but only examine the first namelen
  * characters of name for matching the property name.
  */
+#ifndef SWIG /* Not available in Python */
 const struct fdt_property *fdt_get_property_namelen(const void *fdt,
                                                    int nodeoffset,
                                                    const char *name,
                                                    int namelen, int *lenp);
+#endif
 
 /**
  * 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,
  *             -FDT_ERR_BADSTRUCTURE,
  *             -FDT_ERR_TRUNCATED, standard meanings
  */
+#ifndef SWIG /* This function is not useful in Python */
 const void *fdt_getprop_by_offset(const void *fdt, int offset,
                                  const char **namep, int *lenp);
+#endif
 
 /**
  * fdt_getprop_namelen - get property value based on substring
@@ -638,6 +647,7 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset,
  * Identical to fdt_getprop(), but only examine the first namelen
  * characters of name for matching the property name.
  */
+#ifndef SWIG /* Not available in Python */
 const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
                                const char *name, int namelen, int *lenp);
 static 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,
        return (void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name,
                                                      namelen, lenp);
 }
+#endif
 
 /**
  * fdt_getprop - retrieve the value of a given property
@@ -707,8 +718,10 @@ uint32_t fdt_get_phandle(const void *fdt, int nodeoffset);
  * Identical to fdt_get_alias(), but only examine the first namelen
  * characters of name for matching the alias name.
  */
+#ifndef SWIG /* Not available in Python */
 const char *fdt_get_alias_namelen(const void *fdt,
                                  const char *name, int namelen);
+#endif
 
 /**
  * fdt_get_alias - retrieve the path referenced by a given alias
@@ -1106,10 +1119,12 @@ int fdt_size_cells(const void *fdt, int nodeoffset);
  * of the name. It is useful when you want to manipulate only one value of
  * an array and you have a string that doesn't end with \0.
  */
+#ifndef SWIG /* Not available in Python */
 int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset,
                                        const char *name, int namelen,
                                        uint32_t idx, const void *val,
                                        int len);
+#endif
 
 /**
  * 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,
  *     -FDT_ERR_BADSTRUCTURE,
  *     -FDT_ERR_TRUNCATED, standard meanings
  */
+#ifndef SWIG /* Not available in Python */
 int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
                        const void *val, int len);
+#endif
 
 /**
  * fdt_setprop_inplace_u32 - change the value of a 32-bit integer property
@@ -1297,6 +1314,22 @@ static inline int fdt_property_cell(void *fdt, const char *name, uint32_t val)
 {
        return fdt_property_u32(fdt, name, val);
 }
+
+/**
+ * fdt_property_placeholder - add a new property and return a ptr to its value
+ *
+ * @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
+ *
+ * returns:
+ *     0, on success
+ *     -FDT_ERR_BADMAGIC,
+ *     -FDT_ERR_NOSPACE, standard meanings
+ */
+int fdt_property_placeholder(void *fdt, const char *name, int len, void **valp);
+
 #define fdt_property_string(fdt, name, str) \
        fdt_property(fdt, name, str, strlen(str)+1)
 int fdt_end_node(void *fdt);
@@ -1415,6 +1448,37 @@ int fdt_set_name(void *fdt, int nodeoffset, const char *name);
 int fdt_setprop(void *fdt, int nodeoffset, const char *name,
                const void *val, int len);
 
+/**
+ * fdt_setprop _placeholder - 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
+ * @len: length of the property value
+ * @prop_data: return pointer to property data
+ *
+ * fdt_setprop_placeholer() 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(void *fdt, int nodeoffset, const char *name,
+                           int len, void **prop_data);
+
 /**
  * fdt_setprop_u32 - set a property to a 32-bit integer
  * @fdt: pointer to the device tree blob
@@ -1734,8 +1798,10 @@ int fdt_delprop(void *fdt, int nodeoffset, const char *name);
  * creating subnodes based on a portion of a larger string, such as a
  * full path.
  */
+#ifndef SWIG /* Not available in Python */
 int fdt_add_subnode_namelen(void *fdt, int parentoffset,
                            const char *name, int namelen);
+#endif
 
 /**
  * fdt_add_subnode - creates a new node
index 3673de07e4e58c1d1e86619a4be6f479f1429c08..aecd27875fdde5690fe3a0259d333e0ca3cdf7e5 100644 (file)
@@ -478,7 +478,8 @@ struct node *get_node_by_path(struct node *tree, const char *path)
        p = strchr(path, '/');
 
        for_each_child(tree, child) {
-               if (p && strneq(path, child->name, p-path))
+               if (p && (strlen(child->name) == p-path) &&
+                               strneq(path, child->name, p-path))
                        return get_node_by_path(child, p+1);
                else if (!p && streq(path, child->name))
                        return child;
index 859564e8b4666772235b9b058f7976bc1f3d64f5..b5ed715eccf1895ae42686b01d816df56737373b 100644 (file)
@@ -1 +1 @@
-#define DTC_VERSION "DTC 1.4.4"
+#define DTC_VERSION "DTC 1.4.4-gfe50bd1e"