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
Showing the changes to scripts (10 of 11 files). Show all
Unified · Split
| @@ -259,6 +259,7 @@ quiet_cmd_gzip = GZIP $@ · 258 unmodified lines | |||
| 259 | # DTC | 259 | # DTC |
| 260 | # --------------------------------------------------------------------------- | 260 | # --------------------------------------------------------------------------- |
| 261 | DTC ?= $(objtree)/scripts/dtc/dtc | 261 | DTC ?= $(objtree)/scripts/dtc/dtc |
| 262 | DTC_FLAGS += -Wno-interrupt_provider | ||
| 262 | 263 | ||
| 263 | # Disable noisy checks by default | 264 | # Disable noisy checks by default |
| 264 | ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),) | 265 | ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),) |
| @@ -274,7 +275,8 @@ endif · 9 unmodified lines | |||
| 274 | 275 | ||
| 275 | ifneq ($(findstring 2,$(KBUILD_EXTRA_WARN)),) | 276 | ifneq ($(findstring 2,$(KBUILD_EXTRA_WARN)),) |
| 276 | DTC_FLAGS += -Wnode_name_chars_strict \ | 277 | DTC_FLAGS += -Wnode_name_chars_strict \ |
| 277 | -Wproperty_name_chars_strict | 278 | -Wproperty_name_chars_strict \ |
| 279 | -Winterrupt_provider | ||
| 278 | endif | 280 | endif |
| 279 | 281 | ||
| 280 | DTC_FLAGS += $(DTC_FLAGS_$(basetarget)) | 282 | DTC_FLAGS += $(DTC_FLAGS_$(basetarget)) |
| @@ -1022,6 +1022,9 @@ static void check_i2c_bus_bridge(struct check *c, struct dt_info *dti, struct no · 1021 unmodified lines | |||
| 1022 | } | 1022 | } |
| 1023 | WARNING(i2c_bus_bridge, check_i2c_bus_bridge, NULL, &addr_size_cells); | 1023 | WARNING(i2c_bus_bridge, check_i2c_bus_bridge, NULL, &addr_size_cells); |
| 1024 | 1024 | ||
| 1025 | #define I2C_OWN_SLAVE_ADDRESS (1U << 30) | ||
| 1026 | #define I2C_TEN_BIT_ADDRESS (1U << 31) | ||
| 1027 | |||
| 1025 | static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct node *node) | 1028 | static void check_i2c_bus_reg(struct check *c, struct dt_info *dti, struct node *node) |
| 1026 | { | 1029 | { |
| 1027 | struct property *prop; | 1030 | 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 | |||
| 1044 | } | 1047 | } |
| 1045 | 1048 | ||
| 1046 | reg = fdt32_to_cpu(*cells); | 1049 | reg = fdt32_to_cpu(*cells); |
| 1050 | /* Ignore I2C_OWN_SLAVE_ADDRESS */ | ||
| 1051 | reg &= ~I2C_OWN_SLAVE_ADDRESS; | ||
| 1047 | snprintf(unit_addr, sizeof(unit_addr), "%x", reg); | 1052 | snprintf(unit_addr, sizeof(unit_addr), "%x", reg); |
| 1048 | if (!streq(unitname, unit_addr)) | 1053 | if (!streq(unitname, unit_addr)) |
| 1049 | FAIL(c, dti, node, "I2C bus unit address format error, expected \"%s\"", | 1054 | 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 | |||
| 1051 | 1056 | ||
| 1052 | for (len = prop->val.len; len > 0; len -= 4) { | 1057 | for (len = prop->val.len; len > 0; len -= 4) { |
| 1053 | reg = fdt32_to_cpu(*(cells++)); | 1058 | 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)) | ||
| 1055 | FAIL_PROP(c, dti, node, prop, "I2C address must be less than 10-bits, got \"0x%x\"", | 1063 | FAIL_PROP(c, dti, node, prop, "I2C address must be less than 10-bits, got \"0x%x\"", |
| 1056 | reg); | 1064 | 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); | ||
| 1058 | } | 1068 | } |
| 1059 | } | 1069 | } |
| 1060 | WARNING(i2c_bus_reg, check_i2c_bus_reg, NULL, ®_format, &i2c_bus_bridge); | 1070 | WARNING(i2c_bus_reg, check_i2c_bus_reg, NULL, ®_format, &i2c_bus_bridge); |
| @@ -1547,6 +1557,28 @@ static bool node_is_interrupt_provider(struct node *node) · 486 unmodified lines | |||
| 1547 | 1557 | ||
| 1548 | return false; | 1558 | return false; |
| 1549 | } | 1559 | } |
| 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 | |||
| 1550 | static void check_interrupts_property(struct check *c, | 1582 | static void check_interrupts_property(struct check *c, |
| 1551 | struct dt_info *dti, | 1583 | struct dt_info *dti, |
| 1552 | struct node *node) | 1584 | struct node *node) |
| @@ -1604,7 +1636,7 @@ static void check_interrupts_property(struct check *c, · 51 unmodified lines | |||
| 1604 | 1636 | ||
| 1605 | prop = get_property(irq_node, "#interrupt-cells"); | 1637 | prop = get_property(irq_node, "#interrupt-cells"); |
| 1606 | if (!prop) { | 1638 | if (!prop) { |
| 1607 | FAIL(c, dti, irq_node, "Missing #interrupt-cells in interrupt-parent"); | 1639 | /* We warn about that already in another test. */ |
| 1608 | return; | 1640 | return; |
| 1609 | } | 1641 | } |
| 1610 | 1642 | ||
| @@ -1828,6 +1860,7 @@ static struct check *check_table[] = { · 217 unmodified lines | |||
| 1828 | &deprecated_gpio_property, | 1860 | &deprecated_gpio_property, |
| 1829 | &gpios_property, | 1861 | &gpios_property, |
| 1830 | &interrupts_property, | 1862 | &interrupts_property, |
| 1863 | &interrupt_provider, | ||
| 1831 | 1864 | ||
| 1832 | &alias_paths, | 1865 | &alias_paths, |
| 1833 | 1866 | ||
| @@ -51,6 +51,37 @@ extern int annotate; /* annotate .dts with input source location */ · 50 unmodified lines | |||
| 51 | 51 | ||
| 52 | typedef uint32_t cell_t; | 52 | typedef uint32_t cell_t; |
| 53 | 53 | ||
| 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 | } | ||
| 54 | 85 | ||
| 55 | #define streq(a, b) (strcmp((a), (b)) == 0) | 86 | #define streq(a, b) (strcmp((a), (b)) == 0) |
| 56 | #define strstarts(s, prefix) (strncmp((s), (prefix), strlen(prefix)) == 0) | 87 | #define strstarts(s, prefix) (strncmp((s), (prefix), strlen(prefix)) == 0) |
| @@ -156,7 +156,7 @@ static void asm_emit_data(void *e, struct data d) · 155 unmodified lines | |||
| 156 | emit_offset_label(f, m->ref, m->offset); | 156 | emit_offset_label(f, m->ref, m->offset); |
| 157 | 157 | ||
| 158 | while ((d.len - off) >= sizeof(uint32_t)) { | 158 | 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)); |
| 160 | off += sizeof(uint32_t); | 160 | off += sizeof(uint32_t); |
| 161 | } | 161 | } |
| 162 | 162 | ||
| @@ -436,7 +436,7 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize) · 435 unmodified lines | |||
| 436 | return struct_size; | 436 | return struct_size; |
| 437 | } | 437 | } |
| 438 | 438 | ||
| 439 | if (can_assume(LIBFDT_ORDER) | | 439 | if (can_assume(LIBFDT_ORDER) || |
| 440 | !fdt_blocks_misordered_(fdt, mem_rsv_size, struct_size)) { | 440 | !fdt_blocks_misordered_(fdt, mem_rsv_size, struct_size)) { |
| 441 | /* no further work necessary */ | 441 | /* no further work necessary */ |
| 442 | err = fdt_move(fdt, buf, bufsize); | 442 | err = fdt_move(fdt, buf, bufsize); |
| @@ -32,7 +32,7 @@ static int fdt_sw_probe_(void *fdt) · 31 unmodified lines | |||
| 32 | /* 'memrsv' state: Initial state after fdt_create() | 32 | /* 'memrsv' state: Initial state after fdt_create() |
| 33 | * | 33 | * |
| 34 | * Allowed functions: | 34 | * Allowed functions: |
| 35 | * fdt_add_reservmap_entry() | 35 | * fdt_add_reservemap_entry() |
| 36 | * fdt_finish_reservemap() [moves to 'struct' state] | 36 | * fdt_finish_reservemap() [moves to 'struct' state] |
| 37 | */ | 37 | */ |
| 38 | static int fdt_sw_probe_memrsv_(void *fdt) | 38 | static int fdt_sw_probe_memrsv_(void *fdt) |
| @@ -9,6 +9,10 @@ · 8 unmodified lines | |||
| 9 | #include "libfdt_env.h" | 9 | #include "libfdt_env.h" |
| 10 | #include "fdt.h" | 10 | #include "fdt.h" |
| 11 | 11 | ||
| 12 | #ifdef __cplusplus | ||
| 13 | extern "C" { | ||
| 14 | #endif | ||
| 15 | |||
| 12 | #define FDT_FIRST_SUPPORTED_VERSION 0x02 | 16 | #define FDT_FIRST_SUPPORTED_VERSION 0x02 |
| 13 | #define FDT_LAST_SUPPORTED_VERSION 0x11 | 17 | #define FDT_LAST_SUPPORTED_VERSION 0x11 |
| 14 | 18 | ||
| @@ -2069,4 +2073,8 @@ int fdt_overlay_apply(void *fdt, void *fdto); · 2054 unmodified lines | |||
| 2069 | 2073 | ||
| 2070 | const char *fdt_strerror(int errval); | 2074 | const char *fdt_strerror(int errval); |
| 2071 | 2075 | ||
| 2076 | #ifdef __cplusplus | ||
| 2077 | } | ||
| 2078 | #endif | ||
| 2079 | |||
| 2072 | #endif /* LIBFDT_H */ | 2080 | #endif /* LIBFDT_H */ |
| @@ -110,13 +110,13 @@ static void write_propval_int(FILE *f, const char *p, size_t len, size_t width) · 109 unmodified lines | |||
| 110 | fprintf(f, "%02"PRIx8, *(const uint8_t*)p); | 110 | fprintf(f, "%02"PRIx8, *(const uint8_t*)p); |
| 111 | break; | 111 | break; |
| 112 | case 2: | 112 | case 2: |
| 113 | fprintf(f, "0x%02"PRIx16, fdt16_to_cpu(*(const fdt16_t*)p)); | 113 | fprintf(f, "0x%02"PRIx16, dtb_ld16(p)); |
| 114 | break; | 114 | break; |
| 115 | case 4: | 115 | case 4: |
| 116 | fprintf(f, "0x%02"PRIx32, fdt32_to_cpu(*(const fdt32_t*)p)); | 116 | fprintf(f, "0x%02"PRIx32, dtb_ld32(p)); |
| 117 | break; | 117 | break; |
| 118 | case 8: | 118 | case 8: |
| 119 | fprintf(f, "0x%02"PRIx64, fdt64_to_cpu(*(const fdt64_t*)p)); | 119 | fprintf(f, "0x%02"PRIx64, dtb_ld64(p)); |
| 120 | break; | 120 | break; |
| 121 | } | 121 | } |
| 122 | if (p + width < end) | 122 | if (p + width < end) |
| @@ -183,7 +183,7 @@ static enum markertype guess_value_type(struct property *prop) · 60 unmodified lines | |||
| 183 | nnotcelllbl++; | 183 | nnotcelllbl++; |
| 184 | } | 184 | } |
| 185 | 185 | ||
| 186 | if ((p[len-1] == '\0') && (nnotstring == 0) && (nnul < (len-nnul)) | 186 | if ((p[len-1] == '\0') && (nnotstring == 0) && (nnul <= (len-nnul)) |
| 187 | && (nnotstringlbl == 0)) { | 187 | && (nnotstringlbl == 0)) { |
| 188 | return TYPE_STRING; | 188 | return TYPE_STRING; |
| 189 | } else if (((len % sizeof(cell_t)) == 0) && (nnotcelllbl == 0)) { | 189 | } else if (((len % sizeof(cell_t)) == 0) && (nnotcelllbl == 0)) { |
| @@ -1 +1 @@ | |||
| 1 | #define DTC_VERSION "DTC 1.6.0-g87a656ae" | 1 | #define DTC_VERSION "DTC 1.6.0-g9d7888cb" |
| @@ -59,10 +59,10 @@ static void yaml_propval_int(yaml_emitter_t *emitter, struct marker *markers, ch · 58 unmodified lines | |||
| 59 | sprintf(buf, "0x%"PRIx8, *(uint8_t*)(data + off)); | 59 | sprintf(buf, "0x%"PRIx8, *(uint8_t*)(data + off)); |
| 60 | break; | 60 | break; |
| 61 | case 2: | 61 | case 2: |
| 62 | sprintf(buf, "0x%"PRIx16, fdt16_to_cpu(*(fdt16_t*)(data + off))); | 62 | sprintf(buf, "0x%"PRIx16, dtb_ld16(data + off)); |
| 63 | break; | 63 | break; |
| 64 | case 4: | 64 | case 4: |
| 65 | sprintf(buf, "0x%"PRIx32, fdt32_to_cpu(*(fdt32_t*)(data + off))); | 65 | sprintf(buf, "0x%"PRIx32, dtb_ld32(data + off)); |
| 66 | m = markers; | 66 | m = markers; |
| 67 | is_phandle = false; | 67 | is_phandle = false; |
| 68 | for_each_marker_of_type(m, REF_PHANDLE) { | 68 | 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 | |||
| 73 | } | 73 | } |
| 74 | break; | 74 | break; |
| 75 | case 8: | 75 | case 8: |
| 76 | sprintf(buf, "0x%"PRIx64, fdt64_to_cpu(*(fdt64_t*)(data + off))); | 76 | sprintf(buf, "0x%"PRIx64, dtb_ld64(data + off)); |
| 77 | break; | 77 | break; |
| 78 | } | 78 | } |
| 79 | 79 | ||