Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scripts/dtc: Update to upstream version v1.7.0-93-g1df7b047fe43

This adds the following commits from upstream:

1df7b047fe43 pylibfdt/Makefile.pylibfdt: use project's flags to compile the extension
61e88fdcec52 libfdt: overlay: Fix phandle overwrite check for new subtrees
49d30894466e meson: fix installation with meson-python
d54aaf93673c pylibfdt: clean up python build directory
ab86f1e9fda8 pylibfdt: add VERSION.txt to Python sdist
7b8a30eceabe pylibfdt: fix Python version
ff4f17eb5865 pylibfdt/Makefile.pylibfdt: fix Python library being rebuild during install
9e313b14e684 pylibfdt/meson.build: fix Python library being rebuilt during install
d598fc3648ec tests/run_tests.sh: fix Meson library path being dropped
b98239da2f18 tests/meson.build: fix python and yaml tests not running
c17d76ab5e84 checks: Check the overall length of "interrupt-map"
ae26223a056e libfdt: overlay: Refactor overlay_fixup_phandle
4dd831affd01 libfdt: tests: Update test case for overlay_bad_fixup
e6d294200837 tests: Remove two_roots and named_root from LIBTREE_TESTS_L and add all dtb filenames generated by dumptrees to TESTS_TREES_L in Makefile.tests
855c934e26ae tests: fix tests broken under Meson
4fd3f4f0a95d github: enforce testing pylibfdt and yaml support
9ca7d62dbf0b meson: split run-tests by type
bb51223083a4 meson: fix dependencies of tests
e81900635c95 meson: fix pylibfdt missing dependency on libfdt
822123856980 pylibfdt: fix get_mem_rsv for newer Python versions
1fad065080e6 libfdt: overlay: ensure that existing phandles are not overwritten
b0aacd0a7735 github: add windows/msys CI build
ae97d9745862 github: Don't accidentally suppress test errors
057a7dbbb777 github: Display meson test logs on failure
92b5d4e91678 pylibfdt: Remove some apparently deprecated options from setup.py
417e3299dbd1 github: Update to newer checkout action
5e6cefa17e2d fix MinGW format attribute
24f60011fd43 libfdt: Simplify adjustment of values for local fixups
da39ee0e68b6 libfdt: rework shared/static libraries
a669223f7a60 Makefile: do not hardcode the `install` program path
3fbfdd08afd2 libfdt: fix duplicate meson target
dcef5f834ea3 tests: use correct pkg-config when cross compiling
0b8026ff254f meson: allow building from shallow clones
95c74d71f090 treesource: Restore string list output when no type markers
2283dd78eff5 libfdt: fdt_path_offset_namelen: Reject empty path
79b9e326a162 libfdt: fdt_get_alias_namelen: Validate aliases
52157f13ef3d pylibfdt: Support boolean properties
d77433727566 dtc: fix missing string in usage_opts_help
ad8bf9f9aa39 libfdt: Fix fdt_appendprop_addrrange documentation
6c5e189fb952 github: add workflow for Meson builds
a3dc9f006a78 libfdt: rename libfdt-X.Y.Z.so to libfdt.so.X.Y.Z
35019949c4c7 workflows: build: remove setuptools_scm hack
cd3e2304f4a9 pylibfdt: use fallback version in tarballs
0f5864567745 move release version into VERSION.txt
38165954c13b libfdt: add missing version symbols
5e98b5979354 editorconfig: use tab indentation for version.lds
d030a893be25 tests: generate dtbs in Meson build directory
8d8372b13706 tests: fix use of deprecated meson methods
761114effaf7 pylibtfdt: fix use of deprecated meson method
bf6377a98d97 meson: set minimum Meson version to 0.56.0
4c68e4b16b22 libfdt: fix library version to match project version
bdc5c8793a13 meson: allow disabling tests
f088e381f29e Makefile: allow to install libfdt without building executables
6df5328a902c Fix use of <ctype.h> functions
ccf1f62d59ad libfdt: Fix a typo in libfdt.h
71a8b8ef0adf libfdt: meson: Fix linking on macOS linker
589d8c7653c7 dtc: Add an option to generate __local_fixups__ and __fixups__
e8364666d5ac CI: Add build matrix with multiple Linux distributions
3b02a94b486f dtc: Correct invalid dts output with mixed phandles and integers
d4888958d64b tests: Add additional tests for device graph checks
ea3b9a1d2c5a checks: Fix crash in graph_child_address if 'reg' cell size != 1
b2b9671583e9 livetree: fix off-by-one in propval_cell_n() bounds check
ab481e483061 Add definition for a GitHub Actions CI job
c88038c9b8ca Drop obsolete/broken CI definitions
0ac8b30ba5a1 yaml: Depend on libyaml >= 0.2.3
f1657b2fb5be tests: Add test cases for bad endpoint node and remote-endpoint prop checks
44bb89cafd3d checks: Fix segmentation fault in check_graph_node
60bcf1cde1a8 improve documentation for fdt_path_offset()
a6f997bc77d4 add fdt_get_symbol() and fdt_get_symbol_namelen() functions
18f5ec12a10e use fdt_path_getprop_namelen() in fdt_get_alias_namelen()
df093279282c add fdt_path_getprop_namelen() helper
129bb4b78bc6 doc: dt-object-internal: Fix a typo
390f481521c3 fdtoverlay: Drop a a repeated article
9f8b382ed45e manual: Fix and improve documentation about -@
2cdf93a6d402 fdtoverlay: Fix usage string to not mention "<type>"
72fc810c3025 build-sys: add -Wwrite-strings
083ab26da83b tests: fix leaks spotted by ASAN
6f8b28f49609 livetree: fix leak spotted by ASAN
fd68bb8c5658 Make name_node() xstrdup its name argument
4718189c4ca8 Delay xstrdup() of node and property names coming from a flat tree
0b842c3c8199 Make build_property() xstrdup its name argument
9cceabea1ee0 checks: correct I2C 10-bit address check
0d56145938fe yamltree.c: fix -Werror=discarded-qualifiers & -Werror=cast-qual
61fa22b05f69 checks: make check.data const
7a1d72a788e0 checks.c: fix check_msg() leak
ee5799938697 checks.c: fix heap-buffer-overflow
44c9b73801c1 tests: fix -Wwrite-strings
5b60f5104fcc srcpos.c: fix -Wwrite-strings
32174a66efa4 meson: Fix cell overflow tests when running from meson
64a907f08b9b meson.build: bump version to 1.7.0
e3cde0613bfd Add -Wsuggest-attribute=format warning, correct warnings thus generated
41821821101a Use #ifdef NO_VALGRIND
71c19f20b3ef Do not redefine _GNU_SOURCE if already set
039a99414e77 Bump version to v1.7.0
9b62ec84bb2d Merge remote-tracking branch 'gitlab/main'
3f29d6d85c24 pylibfdt: add size_hint parameter for get_path
2022bb10879d checks: Update #{size,address}-cells check for 'dma-ranges'

Signed-off-by: Rob Herring (Arm) <robh@kernel.org>

+539 -158
+48 -37
scripts/dtc/checks.c
··· 31 31 struct check { 32 32 const char *name; 33 33 check_fn fn; 34 - void *data; 34 + const void *data; 35 35 bool warn, error; 36 36 enum checkstatus status; 37 37 bool inprogress; ··· 114 114 } 115 115 116 116 fputs(str, stderr); 117 + free(str); 117 118 } 118 119 119 120 #define FAIL(c, dti, node, ...) \ ··· 208 207 struct node *node) 209 208 { 210 209 struct property *prop; 211 - char *propname = c->data; 210 + const char *propname = c->data; 212 211 213 212 prop = get_property(node, propname); 214 213 if (!prop) ··· 227 226 { 228 227 int rem, l; 229 228 struct property *prop; 230 - char *propname = c->data; 229 + const char *propname = c->data; 231 230 char *str; 232 231 233 232 prop = get_property(node, propname); ··· 255 254 struct node *node) 256 255 { 257 256 struct property *prop; 258 - char *propname = c->data; 257 + const char *propname = c->data; 259 258 260 259 prop = get_property(node, propname); 261 260 if (!prop) ··· 1079 1078 /* Ignore I2C_OWN_SLAVE_ADDRESS */ 1080 1079 reg &= ~I2C_OWN_SLAVE_ADDRESS; 1081 1080 1082 - if ((reg & I2C_TEN_BIT_ADDRESS) && ((reg & ~I2C_TEN_BIT_ADDRESS) > 0x3ff)) 1083 - FAIL_PROP(c, dti, node, prop, "I2C address must be less than 10-bits, got \"0x%x\"", 1081 + if (reg & I2C_TEN_BIT_ADDRESS) { 1082 + if ((reg & ~I2C_TEN_BIT_ADDRESS) > 0x3ff) 1083 + FAIL_PROP(c, dti, node, prop, "I2C address must be less than 10-bits, got \"0x%x\"", 1084 1084 reg); 1085 - else if (reg > 0x7f) 1085 + } else if (reg > 0x7f) 1086 1086 FAIL_PROP(c, dti, node, prop, "I2C address must be less than 7-bits, got \"0x%x\". Set I2C_TEN_BIT_ADDRESS for 10 bit addresses or fix the property", 1087 1087 reg); 1088 1088 } ··· 1110 1108 for_each_child(node, child) { 1111 1109 struct property *prop; 1112 1110 for_each_property(child, prop) { 1113 - if (strprefixeq(prop->name, 4, "spi-")) { 1111 + if (strstarts(prop->name, "spi-")) { 1114 1112 node->bus = &spi_bus; 1115 1113 break; 1116 1114 } ··· 1182 1180 /* skip over 0x for next test */ 1183 1181 unitname += 2; 1184 1182 } 1185 - if (unitname[0] == '0' && isxdigit(unitname[1])) 1183 + if (unitname[0] == '0' && isxdigit((unsigned char)unitname[1])) 1186 1184 FAIL(c, dti, node, "unit name should not have leading 0s"); 1187 1185 } 1188 1186 WARNING(unit_address_format, check_unit_address_format, NULL, ··· 1224 1222 if (!node->parent || node->addr_cells < 0 || node->size_cells < 0) 1225 1223 return; 1226 1224 1227 - if (get_property(node, "ranges") || !node->children) 1225 + if (get_property(node, "ranges") || get_property(node, "dma-ranges") || !node->children) 1228 1226 return; 1229 1227 1230 1228 for_each_child(node, child) { ··· 1234 1232 } 1235 1233 1236 1234 if (!has_reg) 1237 - FAIL(c, dti, node, "unnecessary #address-cells/#size-cells without \"ranges\" or child \"reg\" property"); 1235 + FAIL(c, dti, node, "unnecessary #address-cells/#size-cells without \"ranges\", \"dma-ranges\" or child \"reg\" property"); 1238 1236 } 1239 1237 WARNING(avoid_unnecessary_addr_size, check_avoid_unnecessary_addr_size, NULL, &avoid_default_addr_size); 1240 1238 ··· 1467 1465 struct dt_info *dti, 1468 1466 struct node *node) 1469 1467 { 1470 - struct provider *provider = c->data; 1468 + const struct provider *provider = c->data; 1471 1469 struct property *prop; 1472 1470 1473 1471 prop = get_property(node, provider->prop_name); ··· 1675 1673 parent_cellsize += propval_cell(cellprop); 1676 1674 1677 1675 cell += 1 + parent_cellsize; 1676 + if (cell > map_cells) 1677 + FAIL_PROP(c, dti, node, irq_map_prop, 1678 + "property size (%d) mismatch, expected %zu", 1679 + irq_map_prop->val.len, cell * sizeof(cell_t)); 1678 1680 } 1679 1681 } 1680 1682 WARNING(interrupt_map, check_interrupt_map, NULL, &phandle_references, &addr_size_cells, &interrupt_provider); ··· 1771 1765 get_property(child, "remote-endpoint"))) 1772 1766 continue; 1773 1767 1768 + /* The root node cannot be a port */ 1769 + if (!node->parent) { 1770 + FAIL(c, dti, node, "root node contains endpoint node '%s', potentially misplaced remote-endpoint property", child->name); 1771 + continue; 1772 + } 1774 1773 node->bus = &graph_port_bus; 1775 1774 1776 1775 /* The parent of 'port' nodes can be either 'ports' or a device */ ··· 1788 1777 1789 1778 } 1790 1779 WARNING(graph_nodes, check_graph_nodes, NULL); 1791 - 1792 - static void check_graph_child_address(struct check *c, struct dt_info *dti, 1793 - struct node *node) 1794 - { 1795 - int cnt = 0; 1796 - struct node *child; 1797 - 1798 - if (node->bus != &graph_ports_bus && node->bus != &graph_port_bus) 1799 - return; 1800 - 1801 - for_each_child(node, child) { 1802 - struct property *prop = get_property(child, "reg"); 1803 - 1804 - /* No error if we have any non-zero unit address */ 1805 - if (prop && propval_cell(prop) != 0) 1806 - return; 1807 - 1808 - cnt++; 1809 - } 1810 - 1811 - if (cnt == 1 && node->addr_cells != -1) 1812 - FAIL(c, dti, node, "graph node has single child node '%s', #address-cells/#size-cells are not necessary", 1813 - node->children->name); 1814 - } 1815 - WARNING(graph_child_address, check_graph_child_address, NULL, &graph_nodes); 1816 1780 1817 1781 static void check_graph_reg(struct check *c, struct dt_info *dti, 1818 1782 struct node *node) ··· 1878 1892 remote_node->fullpath); 1879 1893 } 1880 1894 WARNING(graph_endpoint, check_graph_endpoint, NULL, &graph_nodes); 1895 + 1896 + static void check_graph_child_address(struct check *c, struct dt_info *dti, 1897 + struct node *node) 1898 + { 1899 + int cnt = 0; 1900 + struct node *child; 1901 + 1902 + if (node->bus != &graph_ports_bus && node->bus != &graph_port_bus) 1903 + return; 1904 + 1905 + for_each_child(node, child) { 1906 + struct property *prop = get_property(child, "reg"); 1907 + 1908 + /* No error if we have any non-zero unit address */ 1909 + if (prop && propval_cell(prop) != 0 ) 1910 + return; 1911 + 1912 + cnt++; 1913 + } 1914 + 1915 + if (cnt == 1 && node->addr_cells != -1) 1916 + FAIL(c, dti, node, "graph node has single child node '%s', #address-cells/#size-cells are not necessary", 1917 + node->children->name); 1918 + } 1919 + WARNING(graph_child_address, check_graph_child_address, NULL, &graph_nodes, &graph_port, &graph_endpoint); 1881 1920 1882 1921 static struct check *check_table[] = { 1883 1922 &duplicate_node_names, &duplicate_property_names,
+5
scripts/dtc/dtc-parser.y
··· 284 284 DT_PROPNODENAME '=' propdata ';' 285 285 { 286 286 $$ = build_property($1, $3, &@$); 287 + free($1); 287 288 } 288 289 | DT_PROPNODENAME ';' 289 290 { 290 291 $$ = build_property($1, empty_data, &@$); 292 + free($1); 291 293 } 292 294 | DT_DEL_PROP DT_PROPNODENAME ';' 293 295 { 294 296 $$ = build_property_delete($2); 297 + free($2); 295 298 } 296 299 | DT_LABEL propdef 297 300 { ··· 573 570 DT_PROPNODENAME nodedef 574 571 { 575 572 $$ = name_node($2, $1); 573 + free($1); 576 574 } 577 575 | DT_DEL_NODE DT_PROPNODENAME ';' 578 576 { 579 577 $$ = name_node(build_node_delete(&@$), $2); 578 + free($2); 580 579 } 581 580 | DT_OMIT_NO_REF subnode 582 581 {
+8 -1
scripts/dtc/dtc.c
··· 47 47 48 48 /* Usage related data. */ 49 49 static const char usage_synopsis[] = "dtc [options] <input file>"; 50 - static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:a:fb:i:H:sW:E:@AThv"; 50 + static const char usage_short_opts[] = "qI:O:o:V:d:R:S:p:a:fb:i:H:sW:E:@LAThv"; 51 51 static struct option const usage_long_opts[] = { 52 52 {"quiet", no_argument, NULL, 'q'}, 53 53 {"in-format", a_argument, NULL, 'I'}, ··· 67 67 {"warning", a_argument, NULL, 'W'}, 68 68 {"error", a_argument, NULL, 'E'}, 69 69 {"symbols", no_argument, NULL, '@'}, 70 + {"local-fixups", no_argument, NULL, 'L'}, 70 71 {"auto-alias", no_argument, NULL, 'A'}, 71 72 {"annotate", no_argument, NULL, 'T'}, 72 73 {"help", no_argument, NULL, 'h'}, ··· 105 104 "\n\tEnable/disable warnings (prefix with \"no-\")", 106 105 "\n\tEnable/disable errors (prefix with \"no-\")", 107 106 "\n\tEnable generation of symbols", 107 + "\n\tPossibly generates a __local_fixups__ and a __fixups__ node at the root node", 108 108 "\n\tEnable auto-alias of labels", 109 109 "\n\tAnnotate output .dts with input source file and line (-T -T for more details)", 110 110 "\n\tPrint this help and exit", ··· 254 252 case '@': 255 253 generate_symbols = 1; 256 254 break; 255 + 256 + case 'L': 257 + generate_fixups = 1; 258 + break; 259 + 257 260 case 'A': 258 261 auto_label_aliases = 1; 259 262 break;
+6 -6
scripts/dtc/dtc.h
··· 260 260 void add_label(struct label **labels, char *label); 261 261 void delete_labels(struct label **labels); 262 262 263 - struct property *build_property(char *name, struct data val, 263 + struct property *build_property(const char *name, struct data val, 264 264 struct srcpos *srcpos); 265 - struct property *build_property_delete(char *name); 265 + struct property *build_property_delete(const char *name); 266 266 struct property *chain_property(struct property *first, struct property *list); 267 267 struct property *reverse_properties(struct property *first); 268 268 269 269 struct node *build_node(struct property *proplist, struct node *children, 270 270 struct srcpos *srcpos); 271 271 struct node *build_node_delete(struct srcpos *srcpos); 272 - struct node *name_node(struct node *node, char *name); 272 + struct node *name_node(struct node *node, const char *name); 273 273 struct node *omit_node_if_unused(struct node *node); 274 274 struct node *reference_node(struct node *node); 275 275 struct node *chain_node(struct node *first, struct node *list); ··· 336 336 struct reserve_info *reservelist, 337 337 struct node *tree, uint32_t boot_cpuid_phys); 338 338 void sort_tree(struct dt_info *dti); 339 - void generate_label_tree(struct dt_info *dti, char *name, bool allocph); 340 - void generate_fixups_tree(struct dt_info *dti, char *name); 341 - void generate_local_fixups_tree(struct dt_info *dti, char *name); 339 + void generate_label_tree(struct dt_info *dti, const char *name, bool allocph); 340 + void generate_fixups_tree(struct dt_info *dti, const char *name); 341 + void generate_local_fixups_tree(struct dt_info *dti, const char *name); 342 342 343 343 /* Checks */ 344 344
+2 -4
scripts/dtc/fdtoverlay.c
··· 23 23 /* Usage related data. */ 24 24 static const char usage_synopsis[] = 25 25 "apply a number of overlays to a base blob\n" 26 - " fdtoverlay <options> [<overlay.dtbo> [<overlay.dtbo>]]\n" 27 - "\n" 28 - USAGE_TYPE_MSG; 26 + " fdtoverlay <options> [<overlay.dtbo> [<overlay.dtbo>]]"; 29 27 static const char usage_short_opts[] = "i:o:v" USAGE_COMMON_SHORT_OPTS; 30 28 static struct option const usage_long_opts[] = { 31 29 {"input", required_argument, NULL, 'i'}, ··· 48 50 int ret; 49 51 50 52 /* 51 - * We take a copies first, because a a failed apply can trash 53 + * We take a copies first, because a failed apply can trash 52 54 * both the base blob and the overlay 53 55 */ 54 56 tmpo = xmalloc(fdt_totalsize(overlay));
+9 -12
scripts/dtc/flattree.c
··· 604 604 die("Premature end of data parsing flat device tree\n"); 605 605 } 606 606 607 - static char *flat_read_string(struct inbuf *inb) 607 + static const char *flat_read_string(struct inbuf *inb) 608 608 { 609 609 int len = 0; 610 610 const char *p = inb->ptr; 611 - char *str; 611 + const char *str; 612 612 613 613 do { 614 614 if (p >= inb->limit) ··· 616 616 len++; 617 617 } while ((*p++) != '\0'); 618 618 619 - str = xstrdup(inb->ptr); 619 + str = inb->ptr; 620 620 621 621 inb->ptr += len; 622 622 ··· 711 711 } 712 712 713 713 714 - static char *nodename_from_path(const char *ppath, const char *cpath) 714 + static const char *nodename_from_path(const char *ppath, const char *cpath) 715 715 { 716 716 int plen; 717 717 ··· 725 725 if (!streq(ppath, "/")) 726 726 plen++; 727 727 728 - return xstrdup(cpath + plen); 728 + return cpath + plen; 729 729 } 730 730 731 731 static struct node *unflatten_tree(struct inbuf *dtbuf, ··· 733 733 const char *parent_flatname, int flags) 734 734 { 735 735 struct node *node; 736 - char *flatname; 736 + const char *flatname; 737 737 uint32_t val; 738 738 739 739 node = build_node(NULL, NULL, NULL); ··· 741 741 flatname = flat_read_string(dtbuf); 742 742 743 743 if (flags & FTF_FULLPATH) 744 - node->name = nodename_from_path(parent_flatname, flatname); 744 + node->name = xstrdup(nodename_from_path(parent_flatname, 745 + flatname)); 745 746 else 746 - node->name = flatname; 747 + node->name = xstrdup(flatname); 747 748 748 749 do { 749 750 struct property *prop; ··· 785 784 val); 786 785 } 787 786 } while (val != FDT_END_NODE); 788 - 789 - if (node->name != flatname) { 790 - free(flatname); 791 - } 792 787 793 788 return node; 794 789 }
+1 -1
scripts/dtc/fstree.c
··· 43 43 "WARNING: Cannot open %s: %s\n", 44 44 tmpname, strerror(errno)); 45 45 } else { 46 - prop = build_property(xstrdup(de->d_name), 46 + prop = build_property(de->d_name, 47 47 data_copy_file(pfile, 48 48 st.st_size), 49 49 NULL);
+292 -57
scripts/dtc/libfdt/fdt_overlay.c
··· 101 101 static int overlay_phandle_add_offset(void *fdt, int node, 102 102 const char *name, uint32_t delta) 103 103 { 104 - const fdt32_t *val; 105 - uint32_t adj_val; 104 + fdt32_t *valp, val; 106 105 int len; 107 106 108 - val = fdt_getprop(fdt, node, name, &len); 109 - if (!val) 107 + valp = fdt_getprop_w(fdt, node, name, &len); 108 + if (!valp) 110 109 return len; 111 110 112 - if (len != sizeof(*val)) 111 + if (len != sizeof(val)) 113 112 return -FDT_ERR_BADPHANDLE; 114 113 115 - adj_val = fdt32_to_cpu(*val); 116 - if ((adj_val + delta) < adj_val) 114 + val = fdt32_ld(valp); 115 + if (val + delta < val || val + delta == (uint32_t)-1) 117 116 return -FDT_ERR_NOPHANDLES; 118 117 119 - adj_val += delta; 120 - if (adj_val == (uint32_t)-1) 121 - return -FDT_ERR_NOPHANDLES; 122 - 123 - return fdt_setprop_inplace_u32(fdt, node, name, adj_val); 118 + fdt32_st(valp, val + delta); 119 + return 0; 124 120 } 125 121 126 122 /** ··· 209 213 210 214 fdt_for_each_property_offset(fixup_prop, fdto, fixup_node) { 211 215 const fdt32_t *fixup_val; 212 - const char *tree_val; 213 216 const char *name; 217 + char *tree_val; 214 218 int fixup_len; 215 219 int tree_len; 216 220 int i; ··· 224 228 return -FDT_ERR_BADOVERLAY; 225 229 fixup_len /= sizeof(uint32_t); 226 230 227 - tree_val = fdt_getprop(fdto, tree_node, name, &tree_len); 231 + tree_val = fdt_getprop_w(fdto, tree_node, name, &tree_len); 228 232 if (!tree_val) { 229 233 if (tree_len == -FDT_ERR_NOTFOUND) 230 234 return -FDT_ERR_BADOVERLAY; ··· 233 237 } 234 238 235 239 for (i = 0; i < fixup_len; i++) { 236 - fdt32_t adj_val; 237 - uint32_t poffset; 240 + fdt32_t *refp; 238 241 239 - poffset = fdt32_to_cpu(fixup_val[i]); 242 + refp = (fdt32_t *)(tree_val + fdt32_ld_(fixup_val + i)); 240 243 241 244 /* 242 - * phandles to fixup can be unaligned. 243 - * 244 - * Use a memcpy for the architectures that do 245 - * not support unaligned accesses. 245 + * phandles to fixup can be unaligned, so use 246 + * fdt32_{ld,st}() to read/write them. 246 247 */ 247 - memcpy(&adj_val, tree_val + poffset, sizeof(adj_val)); 248 - 249 - adj_val = cpu_to_fdt32(fdt32_to_cpu(adj_val) + delta); 250 - 251 - ret = fdt_setprop_inplace_namelen_partial(fdto, 252 - tree_node, 253 - name, 254 - strlen(name), 255 - poffset, 256 - &adj_val, 257 - sizeof(adj_val)); 258 - if (ret == -FDT_ERR_NOSPACE) 259 - return -FDT_ERR_BADOVERLAY; 260 - 261 - if (ret) 262 - return ret; 248 + fdt32_st(refp, fdt32_ld(refp) + delta); 263 249 } 264 250 } 265 251 ··· 315 337 * @name: Name of the property holding the phandle reference in the overlay 316 338 * @name_len: number of name characters to consider 317 339 * @poffset: Offset within the overlay property where the phandle is stored 318 - * @label: Label of the node referenced by the phandle 340 + * @phandle: Phandle referencing the node 319 341 * 320 342 * overlay_fixup_one_phandle() resolves an overlay phandle pointing to 321 343 * a node in the base device tree. ··· 332 354 int symbols_off, 333 355 const char *path, uint32_t path_len, 334 356 const char *name, uint32_t name_len, 335 - int poffset, const char *label) 357 + int poffset, uint32_t phandle) 336 358 { 337 - const char *symbol_path; 338 - uint32_t phandle; 339 359 fdt32_t phandle_prop; 340 - int symbol_off, fixup_off; 341 - int prop_len; 360 + int fixup_off; 342 361 343 362 if (symbols_off < 0) 344 363 return symbols_off; 345 - 346 - symbol_path = fdt_getprop(fdt, symbols_off, label, 347 - &prop_len); 348 - if (!symbol_path) 349 - return prop_len; 350 - 351 - symbol_off = fdt_path_offset(fdt, symbol_path); 352 - if (symbol_off < 0) 353 - return symbol_off; 354 - 355 - phandle = fdt_get_phandle(fdt, symbol_off); 356 - if (!phandle) 357 - return -FDT_ERR_NOTFOUND; 358 364 359 365 fixup_off = fdt_path_offset_namelen(fdto, path, path_len); 360 366 if (fixup_off == -FDT_ERR_NOTFOUND) ··· 378 416 const char *value; 379 417 const char *label; 380 418 int len; 419 + const char *symbol_path; 420 + int prop_len; 421 + int symbol_off; 422 + uint32_t phandle; 381 423 382 424 value = fdt_getprop_by_offset(fdto, property, 383 425 &label, &len); ··· 391 425 392 426 return len; 393 427 } 428 + 429 + symbol_path = fdt_getprop(fdt, symbols_off, label, &prop_len); 430 + if (!symbol_path) 431 + return prop_len; 432 + 433 + symbol_off = fdt_path_offset(fdt, symbol_path); 434 + if (symbol_off < 0) 435 + return symbol_off; 436 + 437 + phandle = fdt_get_phandle(fdt, symbol_off); 438 + if (!phandle) 439 + return -FDT_ERR_NOTFOUND; 394 440 395 441 do { 396 442 const char *path, *name, *fixup_end; ··· 445 467 446 468 ret = overlay_fixup_one_phandle(fdt, fdto, symbols_off, 447 469 path, path_len, name, name_len, 448 - poffset, label); 470 + poffset, phandle); 449 471 if (ret) 450 472 return ret; 451 473 } while (len > 0); ··· 491 513 int ret; 492 514 493 515 ret = overlay_fixup_phandle(fdt, fdto, symbols_off, property); 516 + if (ret) 517 + return ret; 518 + } 519 + 520 + return 0; 521 + } 522 + 523 + /** 524 + * overlay_adjust_local_conflicting_phandle: Changes a phandle value 525 + * @fdto: Device tree overlay 526 + * @node: The node the phandle is set for 527 + * @fdt_phandle: The new value for the phandle 528 + * 529 + * returns: 530 + * 0 on success 531 + * Negative error code on failure 532 + */ 533 + static int overlay_adjust_local_conflicting_phandle(void *fdto, int node, 534 + uint32_t fdt_phandle) 535 + { 536 + const fdt32_t *php; 537 + int len, ret; 538 + 539 + php = fdt_getprop(fdto, node, "phandle", &len); 540 + if (php && len == sizeof(*php)) { 541 + ret = fdt_setprop_inplace_u32(fdto, node, "phandle", fdt_phandle); 542 + if (ret) 543 + return ret; 544 + } 545 + 546 + php = fdt_getprop(fdto, node, "linux,phandle", &len); 547 + if (php && len == sizeof(*php)) { 548 + ret = fdt_setprop_inplace_u32(fdto, node, "linux,phandle", fdt_phandle); 549 + if (ret) 550 + return ret; 551 + } 552 + 553 + return 0; 554 + } 555 + 556 + /** 557 + * overlay_update_node_conflicting_references - Recursively replace phandle values 558 + * @fdto: Device tree overlay blob 559 + * @tree_node: Node to recurse into 560 + * @fixup_node: Node offset of the matching local fixups node 561 + * @fdt_phandle: Value to replace phandles with 562 + * @fdto_phandle: Value to be replaced 563 + * 564 + * Replaces all phandles with value @fdto_phandle by @fdt_phandle. 565 + * 566 + * returns: 567 + * 0 on success 568 + * Negative error code on failure 569 + */ 570 + static int overlay_update_node_conflicting_references(void *fdto, int tree_node, 571 + int fixup_node, 572 + uint32_t fdt_phandle, 573 + uint32_t fdto_phandle) 574 + { 575 + int fixup_prop; 576 + int fixup_child; 577 + int ret; 578 + 579 + fdt_for_each_property_offset(fixup_prop, fdto, fixup_node) { 580 + const fdt32_t *fixup_val; 581 + const char *name; 582 + char *tree_val; 583 + int fixup_len; 584 + int tree_len; 585 + int i; 586 + 587 + fixup_val = fdt_getprop_by_offset(fdto, fixup_prop, 588 + &name, &fixup_len); 589 + if (!fixup_val) 590 + return fixup_len; 591 + 592 + if (fixup_len % sizeof(uint32_t)) 593 + return -FDT_ERR_BADOVERLAY; 594 + fixup_len /= sizeof(uint32_t); 595 + 596 + tree_val = fdt_getprop_w(fdto, tree_node, name, &tree_len); 597 + if (!tree_val) { 598 + if (tree_len == -FDT_ERR_NOTFOUND) 599 + return -FDT_ERR_BADOVERLAY; 600 + 601 + return tree_len; 602 + } 603 + 604 + for (i = 0; i < fixup_len; i++) { 605 + fdt32_t *refp; 606 + uint32_t valp; 607 + 608 + refp = (fdt32_t *)(tree_val + fdt32_ld_(fixup_val + i)); 609 + valp = fdt32_ld(refp); 610 + 611 + if (valp == fdto_phandle) 612 + fdt32_st(refp, fdt_phandle); 613 + } 614 + } 615 + 616 + fdt_for_each_subnode(fixup_child, fdto, fixup_node) { 617 + const char *fixup_child_name = fdt_get_name(fdto, fixup_child, NULL); 618 + int tree_child; 619 + 620 + tree_child = fdt_subnode_offset(fdto, tree_node, fixup_child_name); 621 + 622 + if (tree_child == -FDT_ERR_NOTFOUND) 623 + return -FDT_ERR_BADOVERLAY; 624 + if (tree_child < 0) 625 + return tree_child; 626 + 627 + ret = overlay_update_node_conflicting_references(fdto, tree_child, 628 + fixup_child, 629 + fdt_phandle, 630 + fdto_phandle); 631 + if (ret) 632 + return ret; 633 + } 634 + 635 + return 0; 636 + } 637 + 638 + /** 639 + * overlay_update_local_conflicting_references - Recursively replace phandle values 640 + * @fdto: Device tree overlay blob 641 + * @fdt_phandle: Value to replace phandles with 642 + * @fdto_phandle: Value to be replaced 643 + * 644 + * Replaces all phandles with value @fdto_phandle by @fdt_phandle. 645 + * 646 + * returns: 647 + * 0 on success 648 + * Negative error code on failure 649 + */ 650 + static int overlay_update_local_conflicting_references(void *fdto, 651 + uint32_t fdt_phandle, 652 + uint32_t fdto_phandle) 653 + { 654 + int fixups; 655 + 656 + fixups = fdt_path_offset(fdto, "/__local_fixups__"); 657 + if (fixups == -FDT_ERR_NOTFOUND) 658 + return 0; 659 + if (fixups < 0) 660 + return fixups; 661 + 662 + return overlay_update_node_conflicting_references(fdto, 0, fixups, 663 + fdt_phandle, 664 + fdto_phandle); 665 + } 666 + 667 + /** 668 + * overlay_prevent_phandle_overwrite_node - Helper function for overlay_prevent_phandle_overwrite 669 + * @fdt: Base Device tree blob 670 + * @fdtnode: Node in fdt that is checked for an overwrite 671 + * @fdto: Device tree overlay blob 672 + * @fdtonode: Node in fdto matching @fdtnode 673 + * 674 + * returns: 675 + * 0 on success 676 + * Negative error code on failure 677 + */ 678 + static int overlay_prevent_phandle_overwrite_node(void *fdt, int fdtnode, 679 + void *fdto, int fdtonode) 680 + { 681 + uint32_t fdt_phandle, fdto_phandle; 682 + int fdtochild; 683 + 684 + fdt_phandle = fdt_get_phandle(fdt, fdtnode); 685 + fdto_phandle = fdt_get_phandle(fdto, fdtonode); 686 + 687 + if (fdt_phandle && fdto_phandle) { 688 + int ret; 689 + 690 + ret = overlay_adjust_local_conflicting_phandle(fdto, fdtonode, 691 + fdt_phandle); 692 + if (ret) 693 + return ret; 694 + 695 + ret = overlay_update_local_conflicting_references(fdto, 696 + fdt_phandle, 697 + fdto_phandle); 698 + if (ret) 699 + return ret; 700 + } 701 + 702 + fdt_for_each_subnode(fdtochild, fdto, fdtonode) { 703 + const char *name = fdt_get_name(fdto, fdtochild, NULL); 704 + int fdtchild; 705 + int ret; 706 + 707 + fdtchild = fdt_subnode_offset(fdt, fdtnode, name); 708 + if (fdtchild == -FDT_ERR_NOTFOUND) 709 + /* 710 + * no further overwrites possible here as this node is 711 + * new 712 + */ 713 + continue; 714 + 715 + ret = overlay_prevent_phandle_overwrite_node(fdt, fdtchild, 716 + fdto, fdtochild); 717 + if (ret) 718 + return ret; 719 + } 720 + 721 + return 0; 722 + } 723 + 724 + /** 725 + * overlay_prevent_phandle_overwrite - Fixes overlay phandles to not overwrite base phandles 726 + * @fdt: Base Device Tree blob 727 + * @fdto: Device tree overlay blob 728 + * 729 + * Checks recursively if applying fdto overwrites phandle values in the base 730 + * dtb. When such a phandle is found, the fdto is changed to use the fdt's 731 + * phandle value to not break references in the base. 732 + * 733 + * returns: 734 + * 0 on success 735 + * Negative error code on failure 736 + */ 737 + static int overlay_prevent_phandle_overwrite(void *fdt, void *fdto) 738 + { 739 + int fragment; 740 + 741 + fdt_for_each_subnode(fragment, fdto, 0) { 742 + int overlay; 743 + int target; 744 + int ret; 745 + 746 + overlay = fdt_subnode_offset(fdto, fragment, "__overlay__"); 747 + if (overlay == -FDT_ERR_NOTFOUND) 748 + continue; 749 + 750 + if (overlay < 0) 751 + return overlay; 752 + 753 + target = fdt_overlay_target_offset(fdt, fdto, fragment, NULL); 754 + if (target == -FDT_ERR_NOTFOUND) 755 + /* 756 + * The subtree doesn't exist in the base, so nothing 757 + * will be overwritten. 758 + */ 759 + continue; 760 + else if (target < 0) 761 + return target; 762 + 763 + ret = overlay_prevent_phandle_overwrite_node(fdt, target, 764 + fdto, overlay); 494 765 if (ret) 495 766 return ret; 496 767 } ··· 1051 824 if (ret) 1052 825 goto err; 1053 826 827 + /* Increase all phandles in the fdto by delta */ 1054 828 ret = overlay_adjust_local_phandles(fdto, delta); 1055 829 if (ret) 1056 830 goto err; 1057 831 832 + /* Adapt the phandle values in fdto to the above increase */ 1058 833 ret = overlay_update_local_references(fdto, delta); 1059 834 if (ret) 1060 835 goto err; 1061 836 837 + /* Update fdto's phandles using symbols from fdt */ 1062 838 ret = overlay_fixup_phandles(fdt, fdto); 839 + if (ret) 840 + goto err; 841 + 842 + /* Don't overwrite phandles in fdt */ 843 + ret = overlay_prevent_phandle_overwrite(fdt, fdto); 1063 844 if (ret) 1064 845 goto err; 1065 846
+33 -4
scripts/dtc/libfdt/fdt_ro.c
··· 255 255 256 256 FDT_RO_PROBE(fdt); 257 257 258 + if (!can_assume(VALID_INPUT) && namelen <= 0) 259 + return -FDT_ERR_BADPATH; 260 + 258 261 /* see if we have an alias */ 259 262 if (*path != '/') { 260 263 const char *q = memchr(path, '/', end - p); ··· 525 522 return fdt32_ld_(php); 526 523 } 527 524 525 + static const void *fdt_path_getprop_namelen(const void *fdt, const char *path, 526 + const char *propname, int propnamelen, 527 + int *lenp) 528 + { 529 + int offset = fdt_path_offset(fdt, path); 530 + 531 + if (offset < 0) 532 + return NULL; 533 + 534 + return fdt_getprop_namelen(fdt, offset, propname, propnamelen, lenp); 535 + } 536 + 528 537 const char *fdt_get_alias_namelen(const void *fdt, 529 538 const char *name, int namelen) 530 539 { 531 - int aliasoffset; 540 + int len; 541 + const char *alias; 532 542 533 - aliasoffset = fdt_path_offset(fdt, "/aliases"); 534 - if (aliasoffset < 0) 543 + alias = fdt_path_getprop_namelen(fdt, "/aliases", name, namelen, &len); 544 + 545 + if (!can_assume(VALID_DTB) && 546 + !(alias && len > 0 && alias[len - 1] == '\0' && *alias == '/')) 535 547 return NULL; 536 548 537 - return fdt_getprop_namelen(fdt, aliasoffset, name, namelen, NULL); 549 + return alias; 538 550 } 539 551 540 552 const char *fdt_get_alias(const void *fdt, const char *name) 541 553 { 542 554 return fdt_get_alias_namelen(fdt, name, strlen(name)); 555 + } 556 + 557 + const char *fdt_get_symbol_namelen(const void *fdt, 558 + const char *name, int namelen) 559 + { 560 + return fdt_path_getprop_namelen(fdt, "/__symbols__", name, namelen, NULL); 561 + } 562 + 563 + const char *fdt_get_symbol(const void *fdt, const char *name) 564 + { 565 + return fdt_get_symbol_namelen(fdt, name, strlen(name)); 543 566 } 544 567 545 568 int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen)
+64 -3
scripts/dtc/libfdt/libfdt.h
··· 524 524 * level matching the given component, differentiated only by unit 525 525 * address). 526 526 * 527 + * If the path is not absolute (i.e. does not begin with '/'), the 528 + * first component is treated as an alias. That is, the property by 529 + * that name is looked up in the /aliases node, and the value of that 530 + * property used in place of that first component. 531 + * 532 + * For example, for this small fragment 533 + * 534 + * / { 535 + * aliases { 536 + * i2c2 = &foo; // RHS compiles to "/soc@0/i2c@30a40000/eeprom@52" 537 + * }; 538 + * soc@0 { 539 + * foo: i2c@30a40000 { 540 + * bar: eeprom@52 { 541 + * }; 542 + * }; 543 + * }; 544 + * }; 545 + * 546 + * these would be equivalent: 547 + * 548 + * /soc@0/i2c@30a40000/eeprom@52 549 + * i2c2/eeprom@52 550 + * 527 551 * returns: 528 552 * structure block offset of the node with the requested path (>=0), on 529 553 * success 530 - * -FDT_ERR_BADPATH, given path does not begin with '/' or is invalid 554 + * -FDT_ERR_BADPATH, given path does not begin with '/' and the first 555 + * component is not a valid alias 531 556 * -FDT_ERR_NOTFOUND, if the requested node does not exist 532 557 * -FDT_ERR_BADMAGIC, 533 558 * -FDT_ERR_BADVERSION, ··· 893 868 * NULL, if the given alias or the /aliases node does not exist 894 869 */ 895 870 const char *fdt_get_alias(const void *fdt, const char *name); 871 + 872 + /** 873 + * fdt_get_symbol_namelen - get symbol based on substring 874 + * @fdt: pointer to the device tree blob 875 + * @name: name of the symbol to look up 876 + * @namelen: number of characters of name to consider 877 + * 878 + * Identical to fdt_get_symbol(), but only examine the first @namelen 879 + * characters of @name for matching the symbol name. 880 + * 881 + * Return: a pointer to the expansion of the symbol named @name, if it exists, 882 + * NULL otherwise 883 + */ 884 + #ifndef SWIG /* Not available in Python */ 885 + const char *fdt_get_symbol_namelen(const void *fdt, 886 + const char *name, int namelen); 887 + #endif 888 + 889 + /** 890 + * fdt_get_symbol - retrieve the path referenced by a given symbol 891 + * @fdt: pointer to the device tree blob 892 + * @name: name of the symbol to look up 893 + * 894 + * fdt_get_symbol() retrieves the value of a given symbol. That is, 895 + * the value of the property named @name in the node 896 + * /__symbols__. Such a node exists only for a device tree blob that 897 + * has been compiled with the -@ dtc option. Each property corresponds 898 + * to a label appearing in the device tree source, with the name of 899 + * the property being the label and the value being the full path of 900 + * the node it is attached to. 901 + * 902 + * returns: 903 + * a pointer to the expansion of the symbol named 'name', if it exists 904 + * NULL, if the given symbol or the /__symbols__ node does not exist 905 + */ 906 + const char *fdt_get_symbol(const void *fdt, const char *name); 896 907 897 908 /** 898 909 * fdt_get_path - determine the full path of a node ··· 1511 1450 * fdt_create_with_flags() begins the process of creating a new fdt with 1512 1451 * the sequential write interface. 1513 1452 * 1514 - * fdt creation process must end with fdt_finished() to produce a valid fdt. 1453 + * fdt creation process must end with fdt_finish() to produce a valid fdt. 1515 1454 * 1516 1455 * returns: 1517 1456 * 0, on success ··· 2029 1968 * address and size) to the value of the named property in the given 2030 1969 * node, or creates a new property with that value if it does not 2031 1970 * already exist. 2032 - * If "name" is not specified, a default "reg" is used. 1971 + * 2033 1972 * Cell sizes are determined by parent's #address-cells and #size-cells. 2034 1973 * 2035 1974 * This function may insert data into the blob, and will therefore
+32 -24
scripts/dtc/livetree.c
··· 36 36 label->deleted = 1; 37 37 } 38 38 39 - struct property *build_property(char *name, struct data val, 39 + struct property *build_property(const char *name, struct data val, 40 40 struct srcpos *srcpos) 41 41 { 42 42 struct property *new = xmalloc(sizeof(*new)); 43 43 44 44 memset(new, 0, sizeof(*new)); 45 45 46 - new->name = name; 46 + new->name = xstrdup(name); 47 47 new->val = val; 48 48 new->srcpos = srcpos_copy(srcpos); 49 49 50 50 return new; 51 51 } 52 52 53 - struct property *build_property_delete(char *name) 53 + struct property *build_property_delete(const char *name) 54 54 { 55 55 struct property *new = xmalloc(sizeof(*new)); 56 56 57 57 memset(new, 0, sizeof(*new)); 58 58 59 - new->name = name; 59 + new->name = xstrdup(name); 60 60 new->deleted = 1; 61 61 62 62 return new; ··· 116 116 return new; 117 117 } 118 118 119 - struct node *name_node(struct node *node, char *name) 119 + struct node *name_node(struct node *node, const char *name) 120 120 { 121 121 assert(node->name == NULL); 122 122 123 - node->name = name; 123 + node->name = xstrdup(name); 124 124 125 125 return node; 126 126 } ··· 250 250 name_node(new_node, "__overlay__"); 251 251 node = build_node(p, new_node, NULL); 252 252 name_node(node, name); 253 + free(name); 253 254 254 255 add_child(dt, node); 255 256 return dt; ··· 441 440 442 441 cell_t propval_cell_n(struct property *prop, unsigned int n) 443 442 { 444 - assert(prop->val.len / sizeof(cell_t) >= n); 443 + assert(prop->val.len / sizeof(cell_t) > n); 445 444 return fdt32_to_cpu(*((fdt32_t *)prop->val.val + n)); 446 445 } 447 446 ··· 617 616 return target; 618 617 } 619 618 619 + static void add_phandle_property(struct node *node, 620 + const char *name, int format) 621 + { 622 + struct data d; 623 + 624 + if (!(phandle_format & format)) 625 + return; 626 + if (get_property(node, name)) 627 + return; 628 + 629 + d = data_add_marker(empty_data, TYPE_UINT32, NULL); 630 + d = data_append_cell(d, node->phandle); 631 + 632 + add_property(node, build_property(name, d, NULL)); 633 + } 634 + 620 635 cell_t get_node_phandle(struct node *root, struct node *node) 621 636 { 622 637 static cell_t phandle = 1; /* FIXME: ick, static local */ 623 - struct data d = empty_data; 624 638 625 639 if (phandle_is_valid(node->phandle)) 626 640 return node->phandle; ··· 645 629 646 630 node->phandle = phandle; 647 631 648 - d = data_add_marker(d, TYPE_UINT32, NULL); 649 - d = data_append_cell(d, phandle); 650 - 651 - if (!get_property(node, "linux,phandle") 652 - && (phandle_format & PHANDLE_LEGACY)) 653 - add_property(node, build_property("linux,phandle", d, NULL)); 654 - 655 - if (!get_property(node, "phandle") 656 - && (phandle_format & PHANDLE_EPAPR)) 657 - add_property(node, build_property("phandle", d, NULL)); 632 + add_phandle_property(node, "linux,phandle", PHANDLE_LEGACY); 633 + add_phandle_property(node, "phandle", PHANDLE_EPAPR); 658 634 659 635 /* If the node *does* have a phandle property, we must 660 636 * be dealing with a self-referencing phandle, which will be ··· 816 808 } 817 809 818 810 /* utility helper to avoid code duplication */ 819 - static struct node *build_and_name_child_node(struct node *parent, char *name) 811 + static struct node *build_and_name_child_node(struct node *parent, const char *name) 820 812 { 821 813 struct node *node; 822 814 823 815 node = build_node(NULL, NULL, NULL); 824 - name_node(node, xstrdup(name)); 816 + name_node(node, name); 825 817 add_child(parent, node); 826 818 827 819 return node; 828 820 } 829 821 830 - static struct node *build_root_node(struct node *dt, char *name) 822 + static struct node *build_root_node(struct node *dt, const char *name) 831 823 { 832 824 struct node *an; 833 825 ··· 1048 1040 generate_local_fixups_tree_internal(dti, lfn, c); 1049 1041 } 1050 1042 1051 - void generate_label_tree(struct dt_info *dti, char *name, bool allocph) 1043 + void generate_label_tree(struct dt_info *dti, const char *name, bool allocph) 1052 1044 { 1053 1045 if (!any_label_tree(dti, dti->dt)) 1054 1046 return; ··· 1056 1048 dti->dt, allocph); 1057 1049 } 1058 1050 1059 - void generate_fixups_tree(struct dt_info *dti, char *name) 1051 + void generate_fixups_tree(struct dt_info *dti, const char *name) 1060 1052 { 1061 1053 if (!any_fixup_tree(dti, dti->dt)) 1062 1054 return; ··· 1064 1056 dti->dt); 1065 1057 } 1066 1058 1067 - void generate_local_fixups_tree(struct dt_info *dti, char *name) 1059 + void generate_local_fixups_tree(struct dt_info *dti, const char *name) 1068 1060 { 1069 1061 if (!any_local_fixup_tree(dti, dti->dt)) 1070 1062 return;
+8 -6
scripts/dtc/srcpos.c
··· 3 3 * Copyright 2007 Jon Loeliger, Freescale Semiconductor, Inc. 4 4 */ 5 5 6 + #ifndef _GNU_SOURCE 6 7 #define _GNU_SOURCE 8 + #endif 7 9 8 10 #include <stdio.h> 9 11 ··· 313 311 static char * 314 312 srcpos_string_comment(struct srcpos *pos, bool first_line, int level) 315 313 { 316 - char *pos_str, *fname, *first, *rest; 317 - bool fresh_fname = false; 314 + char *pos_str, *fresh_fname = NULL, *first, *rest; 315 + const char *fname; 318 316 319 317 if (!pos) { 320 318 if (level > 1) { ··· 332 330 else if (level > 1) 333 331 fname = pos->file->name; 334 332 else { 335 - fname = shorten_to_initial_path(pos->file->name); 336 - if (fname) 337 - fresh_fname = true; 333 + fresh_fname = shorten_to_initial_path(pos->file->name); 334 + if (fresh_fname) 335 + fname = fresh_fname; 338 336 else 339 337 fname = pos->file->name; 340 338 } ··· 348 346 first_line ? pos->first_line : pos->last_line); 349 347 350 348 if (fresh_fname) 351 - free(fname); 349 + free(fresh_fname); 352 350 353 351 if (pos->next != NULL) { 354 352 rest = srcpos_string_comment(pos->next, first_line, level);
+26
scripts/dtc/treesource.c
··· 139 139 [TYPE_STRING] = "", 140 140 }; 141 141 142 + static void add_string_markers(struct property *prop) 143 + { 144 + int l, len = prop->val.len; 145 + const char *p = prop->val.val; 146 + 147 + for (l = strlen(p) + 1; l < len; l += strlen(p + l) + 1) { 148 + struct marker *m, **nextp; 149 + 150 + m = xmalloc(sizeof(*m)); 151 + m->offset = l; 152 + m->type = TYPE_STRING; 153 + m->ref = NULL; 154 + m->next = NULL; 155 + 156 + /* Find the end of the markerlist */ 157 + nextp = &prop->val.markers; 158 + while (*nextp) 159 + nextp = &((*nextp)->next); 160 + *nextp = m; 161 + } 162 + } 163 + 142 164 static enum markertype guess_value_type(struct property *prop) 143 165 { 144 166 int len = prop->val.len; ··· 186 164 187 165 if ((p[len-1] == '\0') && (nnotstring == 0) && (nnul <= (len-nnul)) 188 166 && (nnotstringlbl == 0)) { 167 + if (nnul > 1) 168 + add_string_markers(prop); 189 169 return TYPE_STRING; 190 170 } else if (((len % sizeof(cell_t)) == 0) && (nnotcelllbl == 0)) { 191 171 return TYPE_UINT32; ··· 265 241 } else { 266 242 write_propval_int(f, p, chunk_len, 4); 267 243 } 244 + if (data_len > chunk_len) 245 + fputc(' ', f); 268 246 break; 269 247 case TYPE_UINT64: 270 248 write_propval_int(f, p, chunk_len, 8);
+4 -2
scripts/dtc/util.h
··· 13 13 */ 14 14 15 15 #ifdef __GNUC__ 16 - #if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) 16 + #ifdef __MINGW_PRINTF_FORMAT 17 + #define PRINTF(i, j) __attribute__((format (__MINGW_PRINTF_FORMAT, i, j))) 18 + #elif __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) 17 19 #define PRINTF(i, j) __attribute__((format (gnu_printf, i, j))) 18 20 #else 19 21 #define PRINTF(i, j) __attribute__((format (printf, i, j))) ··· 67 65 68 66 extern int PRINTF(2, 3) xasprintf(char **strp, const char *fmt, ...); 69 67 extern int PRINTF(2, 3) xasprintf_append(char **strp, const char *fmt, ...); 70 - extern int xavsprintf_append(char **strp, const char *fmt, va_list ap); 68 + extern int PRINTF(2, 0) xavsprintf_append(char **strp, const char *fmt, va_list ap); 71 69 extern char *join_path(const char *path, const char *name); 72 70 73 71 /**
+1 -1
scripts/dtc/version_gen.h
··· 1 - #define DTC_VERSION "DTC 1.6.1-gabbd523b" 1 + #define DTC_VERSION "DTC 1.7.0-g1df7b047"