History

scripts/dtc: Update to upstream version v1.6.0-11-g9d7888cbf19c

Sync with upstream dtc primarily to pickup the I2C bus check fixes. The interrupt_provider check is noisy, so turn it off for now. This adds the following commits from upstream: 9d7888cbf19c dtc: Consider one-character strings as strings 8259d59f59de checks: Improve i2c reg property checking fdabcf2980a4 checks: Remove warning for I2C_OWN_SLAVE_ADDRESS 2478b1652c8d libfdt: add extern "C" for C++ f68bfc2668b2 libfdt: trivial typo fix 7be250b4d059 libfdt: Correct condition for reordering blocks 81e0919a3e21 checks: Add interrupt provider test 85e5d839847a Makefile: when building libfdt only, do not add unneeded deps b28464a550c5 Fix some potential unaligned accesses in dtc

Rob Herring committed 6 years ago

Commit 3eb619b1 parent 8c3105511 files · +91 −16Browse files

Showing the changes to scripts (10 of 11 files). Show all

Unified · Split

10 files
  1. scripts/Makefile.lib +3 −1
  2. scripts/dtc/checks.c +36 −3
  3. scripts/dtc/dtc.h +31 −0
  4. scripts/dtc/flattree.c +1 −1
  5. scripts/dtc/libfdt/fdt_rw.c +1 −1
  6. scripts/dtc/libfdt/fdt_sw.c +1 −1
  7. scripts/dtc/libfdt/libfdt.h +8 −0
  8. scripts/dtc/treesource.c +4 −4
  9. scripts/dtc/version_gen.h +1 −1
  10. scripts/dtc/yamltree.c +3 −3
scripts/Makefile.lib+3−1
@@ -259,6 +259,7 @@ quiet_cmd_gzip = GZIP $@ · 258 unmodified lines
259259 # DTC
260260 # ---------------------------------------------------------------------------
261261 DTC ?= $(objtree)/scripts/dtc/dtc
262+DTC_FLAGS += -Wno-interrupt_provider
262263
263264 # Disable noisy checks by default
264265 ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),)
@@ -274,7 +275,8 @@ endif · 9 unmodified lines
274275
275276 ifneq ($(findstring 2,$(KBUILD_EXTRA_WARN)),)
276277 DTC_FLAGS += -Wnode_name_chars_strict \
277− -Wproperty_name_chars_strict
278+ -Wproperty_name_chars_strict \
279+ -Winterrupt_provider
278280 endif
279281
280282 DTC_FLAGS += $(DTC_FLAGS_$(basetarget))
scripts/dtc/checks.c+36−3
@@ -1022,6 +1022,9 @@ static void check_i2c_bus_bridge(struct check *c, struct dt_info *dti, struct no · 1021 unmodified lines
10221022 }
10231023 WARNING(i2c_bus_bridge, check_i2c_bus_bridge, NULL, &addr_size_cells);
10241024
1025+#define I2C_OWN_SLAVE_ADDRESS (1U << 30)
1026+#define I2C_TEN_BIT_ADDRESS (1U << 31)
1027+
10251028 static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct node *node)
10261029 {
10271030 struct property *prop;
@@ -1044,6 +1047,8 @@ static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct node · 16 unmodified lines
10441047 }
10451048
10461049 reg = fdt32_to_cpu(*cells);
1050+ /* Ignore I2C_OWN_SLAVE_ADDRESS */
1051+ reg &= ~I2C_OWN_SLAVE_ADDRESS;
10471052 snprintf(unit_addr, sizeof(unit_addr), "%x", reg);
10481053 if (!streq(unitname, unit_addr))
10491054 FAIL(c, dti, node, "I2C bus unit address format error, expected \"%s\"",
@@ -1051,10 +1056,15 @@ static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct node · 1 unmodified line
10511056
10521057 for (len = prop->val.len; len > 0; len -= 4) {
10531058 reg = fdt32_to_cpu(*(cells++));
1054− if (reg > 0x3ff)
1059+ /* Ignore I2C_OWN_SLAVE_ADDRESS */
1060+ reg &= ~I2C_OWN_SLAVE_ADDRESS;
1061+
1062+ if ((reg & I2C_TEN_BIT_ADDRESS) && ((reg & ~I2C_TEN_BIT_ADDRESS) > 0x3ff))
10551063 FAIL_PROP(c, dti, node, prop, "I2C address must be less than 10-bits, got \"0x%x\"",
10561064 reg);
1057−
1065+ else if (reg > 0x7f)
1066+ 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",
1067+ reg);
10581068 }
10591069 }
10601070 WARNING(i2c_bus_reg, check_i2c_bus_reg, NULL, &reg_format, &i2c_bus_bridge);
@@ -1547,6 +1557,28 @@ static bool node_is_interrupt_provider(struct node *node) · 486 unmodified lines
15471557
15481558 return false;
15491559 }
1560+
1561+static void check_interrupt_provider(struct check *c,
1562+ struct dt_info *dti,
1563+ struct node *node)
1564+{
1565+ struct property *prop;
1566+
1567+ if (!node_is_interrupt_provider(node))
1568+ return;
1569+
1570+ prop = get_property(node, "#interrupt-cells");
1571+ if (!prop)
1572+ FAIL(c, dti, node,
1573+ "Missing #interrupt-cells in interrupt provider");
1574+
1575+ prop = get_property(node, "#address-cells");
1576+ if (!prop)
1577+ FAIL(c, dti, node,
1578+ "Missing #address-cells in interrupt provider");
1579+}
1580+WARNING(interrupt_provider, check_interrupt_provider, NULL);
1581+
15501582 static void check_interrupts_property(struct check *c,
15511583 struct dt_info *dti,
15521584 struct node *node)
@@ -1604,7 +1636,7 @@ static void check_interrupts_property(struct check *c, · 51 unmodified lines
16041636
16051637 prop = get_property(irq_node, "#interrupt-cells");
16061638 if (!prop) {
1607− FAIL(c, dti, irq_node, "Missing #interrupt-cells in interrupt-parent");
1639+ /* We warn about that already in another test. */
16081640 return;
16091641 }
16101642
@@ -1828,6 +1860,7 @@ static struct check *check_table[] = { · 217 unmodified lines
18281860 &deprecated_gpio_property,
18291861 &gpios_property,
18301862 &interrupts_property,
1863+ &interrupt_provider,
18311864
18321865 &alias_paths,
18331866
scripts/dtc/dtc.h+31−0
@@ -51,6 +51,37 @@ extern int annotate; /* annotate .dts with input source location */ · 50 unmodified lines
5151
5252 typedef uint32_t cell_t;
5353
54+static inline uint16_t dtb_ld16(const void *p)
55+{
56+ const uint8_t *bp = (const uint8_t *)p;
57+
58+ return ((uint16_t)bp[0] << 8)
59+ | bp[1];
60+}
61+
62+static inline uint32_t dtb_ld32(const void *p)
63+{
64+ const uint8_t *bp = (const uint8_t *)p;
65+
66+ return ((uint32_t)bp[0] << 24)
67+ | ((uint32_t)bp[1] << 16)
68+ | ((uint32_t)bp[2] << 8)
69+ | bp[3];
70+}
71+
72+static inline uint64_t dtb_ld64(const void *p)
73+{
74+ const uint8_t *bp = (const uint8_t *)p;
75+
76+ return ((uint64_t)bp[0] << 56)
77+ | ((uint64_t)bp[1] << 48)
78+ | ((uint64_t)bp[2] << 40)
79+ | ((uint64_t)bp[3] << 32)
80+ | ((uint64_t)bp[4] << 24)
81+ | ((uint64_t)bp[5] << 16)
82+ | ((uint64_t)bp[6] << 8)
83+ | bp[7];
84+}
5485
5586 #define streq(a, b) (strcmp((a), (b)) == 0)
5687 #define strstarts(s, prefix) (strncmp((s), (prefix), strlen(prefix)) == 0)
scripts/dtc/flattree.c+1−1
@@ -156,7 +156,7 @@ static void asm_emit_data(void *e, struct data d) · 155 unmodified lines
156156 emit_offset_label(f, m->ref, m->offset);
157157
158158 while ((d.len - off) >= sizeof(uint32_t)) {
159− asm_emit_cell(e, fdt32_to_cpu(*((fdt32_t *)(d.val+off))));
159+ asm_emit_cell(e, dtb_ld32(d.val + off));
160160 off += sizeof(uint32_t);
161161 }
162162
scripts/dtc/libfdt/fdt_rw.c+1−1
@@ -436,7 +436,7 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize) · 435 unmodified lines
436436 return struct_size;
437437 }
438438
439− if (can_assume(LIBFDT_ORDER) |
439+ if (can_assume(LIBFDT_ORDER) ||
440440 !fdt_blocks_misordered_(fdt, mem_rsv_size, struct_size)) {
441441 /* no further work necessary */
442442 err = fdt_move(fdt, buf, bufsize);
scripts/dtc/libfdt/fdt_sw.c+1−1
@@ -32,7 +32,7 @@ static int fdt_sw_probe_(void *fdt) · 31 unmodified lines
3232 /* 'memrsv' state: Initial state after fdt_create()
3333 *
3434 * Allowed functions:
35− * fdt_add_reservmap_entry()
35+ * fdt_add_reservemap_entry()
3636 * fdt_finish_reservemap() [moves to 'struct' state]
3737 */
3838 static int fdt_sw_probe_memrsv_(void *fdt)
scripts/dtc/libfdt/libfdt.h+8−0
@@ -9,6 +9,10 @@ · 8 unmodified lines
99 #include "libfdt_env.h"
1010 #include "fdt.h"
1111
12+#ifdef __cplusplus
13+extern "C" {
14+#endif
15+
1216 #define FDT_FIRST_SUPPORTED_VERSION 0x02
1317 #define FDT_LAST_SUPPORTED_VERSION 0x11
1418
@@ -2069,4 +2073,8 @@ int fdt_overlay_apply(void *fdt, void *fdto); · 2054 unmodified lines
20692073
20702074 const char *fdt_strerror(int errval);
20712075
2076+#ifdef __cplusplus
2077+}
2078+#endif
2079+
20722080 #endif /* LIBFDT_H */
scripts/dtc/treesource.c+4−4
@@ -110,13 +110,13 @@ static void write_propval_int(FILE *f, const char *p, size_t len, size_t width) · 109 unmodified lines
110110 fprintf(f, "%02"PRIx8, *(const uint8_t*)p);
111111 break;
112112 case 2:
113− fprintf(f, "0x%02"PRIx16, fdt16_to_cpu(*(const fdt16_t*)p));
113+ fprintf(f, "0x%02"PRIx16, dtb_ld16(p));
114114 break;
115115 case 4:
116− fprintf(f, "0x%02"PRIx32, fdt32_to_cpu(*(const fdt32_t*)p));
116+ fprintf(f, "0x%02"PRIx32, dtb_ld32(p));
117117 break;
118118 case 8:
119− fprintf(f, "0x%02"PRIx64, fdt64_to_cpu(*(const fdt64_t*)p));
119+ fprintf(f, "0x%02"PRIx64, dtb_ld64(p));
120120 break;
121121 }
122122 if (p + width < end)
@@ -183,7 +183,7 @@ static enum markertype guess_value_type(struct property *prop) · 60 unmodified lines
183183 nnotcelllbl++;
184184 }
185185
186− if ((p[len-1] == '\0') && (nnotstring == 0) && (nnul < (len-nnul))
186+ if ((p[len-1] == '\0') && (nnotstring == 0) && (nnul <= (len-nnul))
187187 && (nnotstringlbl == 0)) {
188188 return TYPE_STRING;
189189 } else if (((len % sizeof(cell_t)) == 0) && (nnotcelllbl == 0)) {
scripts/dtc/version_gen.h+1−1
@@ -1 +1 @@
1−#define DTC_VERSION "DTC 1.6.0-g87a656ae"
1+#define DTC_VERSION "DTC 1.6.0-g9d7888cb"
scripts/dtc/yamltree.c+3−3
@@ -59,10 +59,10 @@ static void yaml_propval_int(yaml_emitter_t *emitter, struct marker *markers, ch · 58 unmodified lines
5959 sprintf(buf, "0x%"PRIx8, *(uint8_t*)(data + off));
6060 break;
6161 case 2:
62− sprintf(buf, "0x%"PRIx16, fdt16_to_cpu(*(fdt16_t*)(data + off)));
62+ sprintf(buf, "0x%"PRIx16, dtb_ld16(data + off));
6363 break;
6464 case 4:
65− sprintf(buf, "0x%"PRIx32, fdt32_to_cpu(*(fdt32_t*)(data + off)));
65+ sprintf(buf, "0x%"PRIx32, dtb_ld32(data + off));
6666 m = markers;
6767 is_phandle = false;
6868 for_each_marker_of_type(m, REF_PHANDLE) {
@@ -73,7 +73,7 @@ static void yaml_propval_int(yaml_emitter_t *emitter, struct marker *markers, ch · 4 unmodified lines
7373 }
7474 break;
7575 case 8:
76− sprintf(buf, "0x%"PRIx64, fdt64_to_cpu(*(fdt64_t*)(data + off)));
76+ sprintf(buf, "0x%"PRIx64, dtb_ld64(data + off));
7777 break;
7878 }
7979