Skip to content

Commit 3eb619b

Browse files
committed
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 Signed-off-by: Rob Herring <[email protected]>
1 parent 8c31055 commit 3eb619b

File tree

11 files changed

+91
-16
lines changed

11 files changed

+91
-16
lines changed

Documentation/devicetree/bindings/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ extra-$(CHECK_DT_BINDING) += processed-schema-examples.yaml
4343

4444
override DTC_FLAGS := \
4545
-Wno-avoid_unnecessary_addr_size \
46-
-Wno-graph_child_address
46+
-Wno-graph_child_address \
47+
-Wno-interrupt_provider
4748

4849
$(obj)/processed-schema-examples.yaml: $(DT_DOCS) check_dtschema_version FORCE
4950
$(call if_changed,mk_schema)

scripts/Makefile.lib

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ quiet_cmd_gzip = GZIP $@
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
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

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,9 @@ static void check_i2c_bus_bridge(struct check *c, struct dt_info *dti, struct no
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,17 +1047,24 @@ static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct node
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\"",
10501055
unit_addr);
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)
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,
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[] = {
18281860
&deprecated_gpio_property,
18291861
&gpios_property,
18301862
&interrupts_property,
1863+
&interrupt_provider,
18311864

18321865
&alias_paths,
18331866

scripts/dtc/dtc.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,37 @@ extern int annotate; /* annotate .dts with input source location */
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ static void asm_emit_data(void *e, struct data d)
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize)
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static int fdt_sw_probe_(void *fdt)
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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
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);
20692073

20702074
const char *fdt_strerror(int errval);
20712075

2076+
#ifdef __cplusplus
2077+
}
2078+
#endif
2079+
20722080
#endif /* LIBFDT_H */

scripts/dtc/treesource.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@ static void write_propval_int(FILE *f, const char *p, size_t len, size_t width)
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)
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
#define DTC_VERSION "DTC 1.6.0-g87a656ae"
1+
#define DTC_VERSION "DTC 1.6.0-g9d7888cb"

0 commit comments

Comments
 (0)