Pull DeviceTree updates from Rob Herring: - fix sparse warnings in drivers/of/ - add more overlay unittests - update dtc to v1.4.4-8-g756ffc4f52f6. This adds more checks on dts files such as unit-address formatting and stricter character sets for node and property names - add a common DT modalias function - move trivial-devices.txt up and out of i2c dir - ARM NVIC interrupt controller binding - vendor prefixes for Sensirion, Dioo, Nordic, ROHM - correct some binding file locations * tag 'devicetree-for-4.12' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: (24 commits) of: fix sparse warnings in fdt, irq, reserved mem, and resolver code of: fix sparse warning in of_pci_range_parser_one of: fix sparse warnings in of_find_next_cache_node of/unittest: Missing unlocks on error of: fix uninitialized variable warning for overlay test of: fix unittest build without CONFIG_OF_OVERLAY of: Add unit tests for applying overlays of: per-file dtc compiler flags fpga: region: add missing DT documentation for config complete timeout of: Add vendor prefix for ROHM Semiconductor of: fix "/cpus" reference leak in of_numa_parse_cpu_nodes() of: Add vendor prefix for Nordic Semiconductor dt-bindings: arm,nvic: Binding for ARM NVIC interrupt controller on Cortex-M dtc: update warning settings for new bus and node/property name checks scripts/dtc: Update to upstream version v1.4.4-8-g756ffc4f52f6 scripts/dtc: automate getting dtc version and log in update script of: Add function for generating a DT modalias with a newline of: fix of_device_get_modalias returned length when truncating buffers Documentation: devicetree: move trivial-devices out of I2C realm dt-bindings: add vendor prefix for Dioo ..
Showing the changes to scripts (21 of 49 files). Show all
Unified · Split
| @@ -280,9 +280,21 @@ DTC ?= $(objtree)/scripts/dtc/dtc · 279 unmodified lines | ||
| 280 | 280 | |
| 281 | 281 | # Disable noisy checks by default |
| 282 | 282 | ifeq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),) |
| 283 | −DTC_FLAGS += -Wno-unit_address_vs_reg | |
| 283 | +DTC_FLAGS += -Wno-unit_address_vs_reg \ | |
| 284 | + -Wno-simple_bus_reg \ | |
| 285 | + -Wno-unit_address_format \ | |
| 286 | + -Wno-pci_bridge \ | |
| 287 | + -Wno-pci_device_bus_num \ | |
| 288 | + -Wno-pci_device_reg | |
| 284 | 289 | endif |
| 285 | 290 | |
| 291 | +ifeq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),2) | |
| 292 | +DTC_FLAGS += -Wnode_name_chars_strict \ | |
| 293 | + -Wproperty_name_chars_strict | |
| 294 | +endif | |
| 295 | + | |
| 296 | +DTC_FLAGS += $(DTC_FLAGS_$(basetarget)) | |
| 297 | + | |
| 286 | 298 | # Generate an assembly file to wrap the output of the device tree compiler |
| 287 | 299 | quiet_cmd_dt_S_dtb= DTB $@ |
| 288 | 300 | cmd_dt_S_dtb= \ |
| @@ -72,17 +72,16 @@ struct check { · 71 unmodified lines | ||
| 72 | 72 | #define CHECK(_nm, _fn, _d, ...) \ |
| 73 | 73 | CHECK_ENTRY(_nm, _fn, _d, false, false, __VA_ARGS__) |
| 74 | 74 | |
| 75 | −#ifdef __GNUC__ | |
| 76 | −static inline void check_msg(struct check *c, const char *fmt, ...) __attribute__((format (printf, 2, 3))); | |
| 77 | −#endif | |
| 78 | −static inline void check_msg(struct check *c, const char *fmt, ...) | |
| 75 | +static inline void PRINTF(3, 4) check_msg(struct check *c, struct dt_info *dti, | |
| 76 | + const char *fmt, ...) | |
| 79 | 77 | { |
| 80 | 78 | va_list ap; |
| 81 | 79 | va_start(ap, fmt); |
| 82 | 80 | |
| 83 | 81 | if ((c->warn && (quiet < 1)) |
| 84 | 82 | || (c->error && (quiet < 2))) { |
| 85 | − fprintf(stderr, "%s (%s): ", | |
| 83 | + fprintf(stderr, "%s: %s (%s): ", | |
| 84 | + strcmp(dti->outname, "-") ? dti->outname : "<stdout>", | |
| 86 | 85 | (c->error) ? "ERROR" : "Warning", c->name); |
| 87 | 86 | vfprintf(stderr, fmt, ap); |
| 88 | 87 | fprintf(stderr, "\n"); |
| @@ -90,11 +89,11 @@ static inline void check_msg(struct check *c, const char *fmt, ...) · 1 unmodified line | ||
| 90 | 89 | va_end(ap); |
| 91 | 90 | } |
| 92 | 91 | |
| 93 | −#define FAIL(c, ...) \ | |
| 94 | − do { \ | |
| 95 | − TRACE((c), "\t\tFAILED at %s:%d", __FILE__, __LINE__); \ | |
| 96 | − (c)->status = FAILED; \ | |
| 97 | − check_msg((c), __VA_ARGS__); \ | |
| 92 | +#define FAIL(c, dti, ...) \ | |
| 93 | + do { \ | |
| 94 | + TRACE((c), "\t\tFAILED at %s:%d", __FILE__, __LINE__); \ | |
| 95 | + (c)->status = FAILED; \ | |
| 96 | + check_msg((c), dti, __VA_ARGS__); \ | |
| 98 | 97 | } while (0) |
| 99 | 98 | |
| 100 | 99 | static void check_nodes_props(struct check *c, struct dt_info *dti, struct node *node) |
| @@ -127,7 +126,7 @@ static bool run_check(struct check *c, struct dt_info *dti) · 26 unmodified lines | ||
| 127 | 126 | error = error || run_check(prq, dti); |
| 128 | 127 | if (prq->status != PASSED) { |
| 129 | 128 | c->status = PREREQ; |
| 130 | − check_msg(c, "Failed prerequisite '%s'", | |
| 129 | + check_msg(c, dti, "Failed prerequisite '%s'", | |
| 131 | 130 | c->prereq[i]->name); |
| 132 | 131 | } |
| 133 | 132 | } |
| @@ -157,7 +156,7 @@ out: · 23 unmodified lines | ||
| 157 | 156 | static inline void check_always_fail(struct check *c, struct dt_info *dti, |
| 158 | 157 | struct node *node) |
| 159 | 158 | { |
| 160 | − FAIL(c, "always_fail check"); | |
| 159 | + FAIL(c, dti, "always_fail check"); | |
| 161 | 160 | } |
| 162 | 161 | CHECK(always_fail, check_always_fail, NULL); |
| 163 | 162 | |
| @@ -172,7 +171,7 @@ static void check_is_string(struct check *c, struct dt_info *dti, · 8 unmodified lines | ||
| 172 | 171 | return; /* Not present, assumed ok */ |
| 173 | 172 | |
| 174 | 173 | if (!data_is_one_string(prop->val)) |
| 175 | − FAIL(c, "\"%s\" property in %s is not a string", | |
| 174 | + FAIL(c, dti, "\"%s\" property in %s is not a string", | |
| 176 | 175 | propname, node->fullpath); |
| 177 | 176 | } |
| 178 | 177 | #define WARNING_IF_NOT_STRING(nm, propname) \ |
| @@ -191,7 +190,7 @@ static void check_is_cell(struct check *c, struct dt_info *dti, · 12 unmodified lines | ||
| 191 | 190 | return; /* Not present, assumed ok */ |
| 192 | 191 | |
| 193 | 192 | if (prop->val.len != sizeof(cell_t)) |
| 194 | − FAIL(c, "\"%s\" property in %s is not a single cell", | |
| 193 | + FAIL(c, dti, "\"%s\" property in %s is not a single cell", | |
| 195 | 194 | propname, node->fullpath); |
| 196 | 195 | } |
| 197 | 196 | #define WARNING_IF_NOT_CELL(nm, propname) \ |
| @@ -213,7 +212,7 @@ static void check_duplicate_node_names(struct check *c, struct dt_info *dti, · 15 unmodified lines | ||
| 213 | 212 | child2; |
| 214 | 213 | child2 = child2->next_sibling) |
| 215 | 214 | if (streq(child->name, child2->name)) |
| 216 | − FAIL(c, "Duplicate node name %s", | |
| 215 | + FAIL(c, dti, "Duplicate node name %s", | |
| 217 | 216 | child->fullpath); |
| 218 | 217 | } |
| 219 | 218 | ERROR(duplicate_node_names, check_duplicate_node_names, NULL); |
| @@ -228,7 +227,7 @@ static void check_duplicate_property_names(struct check *c, struct dt_info *dti, · 8 unmodified lines | ||
| 228 | 227 | if (prop2->deleted) |
| 229 | 228 | continue; |
| 230 | 229 | if (streq(prop->name, prop2->name)) |
| 231 | − FAIL(c, "Duplicate property name %s in %s", | |
| 230 | + FAIL(c, dti, "Duplicate property name %s in %s", | |
| 232 | 231 | prop->name, node->fullpath); |
| 233 | 232 | } |
| 234 | 233 | } |
| @@ -239,6 +238,7 @@ ERROR(duplicate_property_names, check_duplicate_property_names, NULL); · 4 unmodified lines | ||
| 239 | 238 | #define UPPERCASE "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
| 240 | 239 | #define DIGITS "0123456789" |
| 241 | 240 | #define PROPNODECHARS LOWERCASE UPPERCASE DIGITS ",._+*#?-" |
| 241 | +#define PROPNODECHARSSTRICT LOWERCASE UPPERCASE DIGITS ",-" | |
| 242 | 242 | |
| 243 | 243 | static void check_node_name_chars(struct check *c, struct dt_info *dti, |
| 244 | 244 | struct node *node) |
| @@ -246,16 +246,27 @@ static void check_node_name_chars(struct check *c, struct dt_info *dti, · 1 unmodified line | ||
| 246 | 246 | int n = strspn(node->name, c->data); |
| 247 | 247 | |
| 248 | 248 | if (n < strlen(node->name)) |
| 249 | − FAIL(c, "Bad character '%c' in node %s", | |
| 249 | + FAIL(c, dti, "Bad character '%c' in node %s", | |
| 250 | 250 | node->name[n], node->fullpath); |
| 251 | 251 | } |
| 252 | 252 | ERROR(node_name_chars, check_node_name_chars, PROPNODECHARS "@"); |
| 253 | 253 | |
| 254 | +static void check_node_name_chars_strict(struct check *c, struct dt_info *dti, | |
| 255 | + struct node *node) | |
| 256 | +{ | |
| 257 | + int n = strspn(node->name, c->data); | |
| 258 | + | |
| 259 | + if (n < node->basenamelen) | |
| 260 | + FAIL(c, dti, "Character '%c' not recommended in node %s", | |
| 261 | + node->name[n], node->fullpath); | |
| 262 | +} | |
| 263 | +CHECK(node_name_chars_strict, check_node_name_chars_strict, PROPNODECHARSSTRICT); | |
| 264 | + | |
| 254 | 265 | static void check_node_name_format(struct check *c, struct dt_info *dti, |
| 255 | 266 | struct node *node) |
| 256 | 267 | { |
| 257 | 268 | if (strchr(get_unitname(node), '@')) |
| 258 | − FAIL(c, "Node %s has multiple '@' characters in name", | |
| 269 | + FAIL(c, dti, "Node %s has multiple '@' characters in name", | |
| 259 | 270 | node->fullpath); |
| 260 | 271 | } |
| 261 | 272 | ERROR(node_name_format, check_node_name_format, NULL, &node_name_chars); |
| @@ -274,11 +285,11 @@ static void check_unit_address_vs_reg(struct check *c, struct dt_info *dti, · 12 unmodified lines | ||
| 274 | 285 | |
| 275 | 286 | if (prop) { |
| 276 | 287 | if (!unitname[0]) |
| 277 | − FAIL(c, "Node %s has a reg or ranges property, but no unit name", | |
| 288 | + FAIL(c, dti, "Node %s has a reg or ranges property, but no unit name", | |
| 278 | 289 | node->fullpath); |
| 279 | 290 | } else { |
| 280 | 291 | if (unitname[0]) |
| 281 | − FAIL(c, "Node %s has a unit name, but no reg property", | |
| 292 | + FAIL(c, dti, "Node %s has a unit name, but no reg property", | |
| 282 | 293 | node->fullpath); |
| 283 | 294 | } |
| 284 | 295 | } |
| @@ -293,12 +304,44 @@ static void check_property_name_chars(struct check *c, struct dt_info *dti, · 8 unmodified lines | ||
| 293 | 304 | int n = strspn(prop->name, c->data); |
| 294 | 305 | |
| 295 | 306 | if (n < strlen(prop->name)) |
| 296 | − FAIL(c, "Bad character '%c' in property name \"%s\", node %s", | |
| 307 | + FAIL(c, dti, "Bad character '%c' in property name \"%s\", node %s", | |
| 297 | 308 | prop->name[n], prop->name, node->fullpath); |
| 298 | 309 | } |
| 299 | 310 | } |
| 300 | 311 | ERROR(property_name_chars, check_property_name_chars, PROPNODECHARS); |
| 301 | 312 | |
| 313 | +static void check_property_name_chars_strict(struct check *c, | |
| 314 | + struct dt_info *dti, | |
| 315 | + struct node *node) | |
| 316 | +{ | |
| 317 | + struct property *prop; | |
| 318 | + | |
| 319 | + for_each_property(node, prop) { | |
| 320 | + const char *name = prop->name; | |
| 321 | + int n = strspn(name, c->data); | |
| 322 | + | |
| 323 | + if (n == strlen(prop->name)) | |
| 324 | + continue; | |
| 325 | + | |
| 326 | + /* Certain names are whitelisted */ | |
| 327 | + if (streq(name, "device_type")) | |
| 328 | + continue; | |
| 329 | + | |
| 330 | + /* | |
| 331 | + * # is only allowed at the beginning of property names not counting | |
| 332 | + * the vendor prefix. | |
| 333 | + */ | |
| 334 | + if (name[n] == '#' && ((n == 0) || (name[n-1] == ','))) { | |
| 335 | + name += n + 1; | |
| 336 | + n = strspn(name, c->data); | |
| 337 | + } | |
| 338 | + if (n < strlen(name)) | |
| 339 | + FAIL(c, dti, "Character '%c' not recommended in property name \"%s\", node %s", | |
| 340 | + name[n], prop->name, node->fullpath); | |
| 341 | + } | |
| 342 | +} | |
| 343 | +CHECK(property_name_chars_strict, check_property_name_chars_strict, PROPNODECHARSSTRICT); | |
| 344 | + | |
| 302 | 345 | #define DESCLABEL_FMT "%s%s%s%s%s" |
| 303 | 346 | #define DESCLABEL_ARGS(node,prop,mark) \ |
| 304 | 347 | ((mark) ? "value of " : ""), \ |
| @@ -327,7 +370,7 @@ static void check_duplicate_label(struct check *c, struct dt_info *dti, · 22 unmodified lines | ||
| 327 | 370 | return; |
| 328 | 371 | |
| 329 | 372 | if ((othernode != node) || (otherprop != prop) || (othermark != mark)) |
| 330 | − FAIL(c, "Duplicate label '%s' on " DESCLABEL_FMT | |
| 373 | + FAIL(c, dti, "Duplicate label '%s' on " DESCLABEL_FMT | |
| 331 | 374 | " and " DESCLABEL_FMT, |
| 332 | 375 | label, DESCLABEL_ARGS(node, prop, mark), |
| 333 | 376 | DESCLABEL_ARGS(othernode, otherprop, othermark)); |
| @@ -367,7 +410,7 @@ static cell_t check_phandle_prop(struct check *c, struct dt_info *dti, · 33 unmodified lines | ||
| 367 | 410 | return 0; |
| 368 | 411 | |
| 369 | 412 | if (prop->val.len != sizeof(cell_t)) { |
| 370 | − FAIL(c, "%s has bad length (%d) %s property", | |
| 413 | + FAIL(c, dti, "%s has bad length (%d) %s property", | |
| 371 | 414 | node->fullpath, prop->val.len, prop->name); |
| 372 | 415 | return 0; |
| 373 | 416 | } |
| @@ -379,7 +422,7 @@ static cell_t check_phandle_prop(struct check *c, struct dt_info *dti, · 5 unmodified lines | ||
| 379 | 422 | /* "Set this node's phandle equal to some |
| 380 | 423 | * other node's phandle". That's nonsensical |
| 381 | 424 | * by construction. */ { |
| 382 | − FAIL(c, "%s in %s is a reference to another node", | |
| 425 | + FAIL(c, dti, "%s in %s is a reference to another node", | |
| 383 | 426 | prop->name, node->fullpath); |
| 384 | 427 | } |
| 385 | 428 | /* But setting this node's phandle equal to its own |
| @@ -393,7 +436,7 @@ static cell_t check_phandle_prop(struct check *c, struct dt_info *dti, · 7 unmodified lines | ||
| 393 | 436 | phandle = propval_cell(prop); |
| 394 | 437 | |
| 395 | 438 | if ((phandle == 0) || (phandle == -1)) { |
| 396 | − FAIL(c, "%s has bad value (0x%x) in %s property", | |
| 439 | + FAIL(c, dti, "%s has bad value (0x%x) in %s property", | |
| 397 | 440 | node->fullpath, phandle, prop->name); |
| 398 | 441 | return 0; |
| 399 | 442 | } |
| @@ -420,7 +463,7 @@ static void check_explicit_phandles(struct check *c, struct dt_info *dti, · 20 unmodified lines | ||
| 420 | 463 | return; |
| 421 | 464 | |
| 422 | 465 | if (linux_phandle && phandle && (phandle != linux_phandle)) |
| 423 | − FAIL(c, "%s has mismatching 'phandle' and 'linux,phandle'" | |
| 466 | + FAIL(c, dti, "%s has mismatching 'phandle' and 'linux,phandle'" | |
| 424 | 467 | " properties", node->fullpath); |
| 425 | 468 | |
| 426 | 469 | if (linux_phandle && !phandle) |
| @@ -428,7 +471,7 @@ static void check_explicit_phandles(struct check *c, struct dt_info *dti, · 1 unmodified line | ||
| 428 | 471 | |
| 429 | 472 | other = get_node_by_phandle(root, phandle); |
| 430 | 473 | if (other && (other != node)) { |
| 431 | − FAIL(c, "%s has duplicated phandle 0x%x (seen before at %s)", | |
| 474 | + FAIL(c, dti, "%s has duplicated phandle 0x%x (seen before at %s)", | |
| 432 | 475 | node->fullpath, phandle, other->fullpath); |
| 433 | 476 | return; |
| 434 | 477 | } |
| @@ -453,7 +496,7 @@ static void check_name_properties(struct check *c, struct dt_info *dti, · 18 unmodified lines | ||
| 453 | 496 | |
| 454 | 497 | if ((prop->val.len != node->basenamelen+1) |
| 455 | 498 | || (memcmp(prop->val.val, node->name, node->basenamelen) != 0)) { |
| 456 | − FAIL(c, "\"name\" property in %s is incorrect (\"%s\" instead" | |
| 499 | + FAIL(c, dti, "\"name\" property in %s is incorrect (\"%s\" instead" | |
| 457 | 500 | " of base node name)", node->fullpath, prop->val.val); |
| 458 | 501 | } else { |
| 459 | 502 | /* The name property is correct, and therefore redundant. |
| @@ -488,16 +531,16 @@ static void fixup_phandle_references(struct check *c, struct dt_info *dti, · 28 unmodified lines | ||
| 488 | 531 | refnode = get_node_by_ref(dt, m->ref); |
| 489 | 532 | if (! refnode) { |
| 490 | 533 | if (!(dti->dtsflags & DTSF_PLUGIN)) |
| 491 | − FAIL(c, "Reference to non-existent node or " | |
| 534 | + FAIL(c, dti, "Reference to non-existent node or " | |
| 492 | 535 | "label \"%s\"\n", m->ref); |
| 493 | 536 | else /* mark the entry as unresolved */ |
| 494 | − *((cell_t *)(prop->val.val + m->offset)) = | |
| 537 | + *((fdt32_t *)(prop->val.val + m->offset)) = | |
| 495 | 538 | cpu_to_fdt32(0xffffffff); |
| 496 | 539 | continue; |
| 497 | 540 | } |
| 498 | 541 | |
| 499 | 542 | phandle = get_node_phandle(dt, refnode); |
| 500 | − *((cell_t *)(prop->val.val + m->offset)) = cpu_to_fdt32(phandle); | |
| 543 | + *((fdt32_t *)(prop->val.val + m->offset)) = cpu_to_fdt32(phandle); | |
| 501 | 544 | } |
| 502 | 545 | } |
| 503 | 546 | } |
| @@ -520,7 +563,7 @@ static void fixup_path_references(struct check *c, struct dt_info *dti, · 16 unmodified lines | ||
| 520 | 563 | |
| 521 | 564 | refnode = get_node_by_ref(dt, m->ref); |
| 522 | 565 | if (!refnode) { |
| 523 | − FAIL(c, "Reference to non-existent node or label \"%s\"\n", | |
| 566 | + FAIL(c, dti, "Reference to non-existent node or label \"%s\"\n", | |
| 524 | 567 | m->ref); |
| 525 | 568 | continue; |
| 526 | 569 | } |
| @@ -579,19 +622,19 @@ static void check_reg_format(struct check *c, struct dt_info *dti, · 52 unmodified lines | ||
| 579 | 622 | return; /* No "reg", that's fine */ |
| 580 | 623 | |
| 581 | 624 | if (!node->parent) { |
| 582 | − FAIL(c, "Root node has a \"reg\" property"); | |
| 625 | + FAIL(c, dti, "Root node has a \"reg\" property"); | |
| 583 | 626 | return; |
| 584 | 627 | } |
| 585 | 628 | |
| 586 | 629 | if (prop->val.len == 0) |
| 587 | − FAIL(c, "\"reg\" property in %s is empty", node->fullpath); | |
| 630 | + FAIL(c, dti, "\"reg\" property in %s is empty", node->fullpath); | |
| 588 | 631 | |
| 589 | 632 | addr_cells = node_addr_cells(node->parent); |
| 590 | 633 | size_cells = node_size_cells(node->parent); |
| 591 | 634 | entrylen = (addr_cells + size_cells) * sizeof(cell_t); |
| 592 | 635 | |
| 593 | 636 | if (!entrylen || (prop->val.len % entrylen) != 0) |
| 594 | − FAIL(c, "\"reg\" property in %s has invalid length (%d bytes) " | |
| 637 | + FAIL(c, dti, "\"reg\" property in %s has invalid length (%d bytes) " | |
| 595 | 638 | "(#address-cells == %d, #size-cells == %d)", |
| 596 | 639 | node->fullpath, prop->val.len, addr_cells, size_cells); |
| 597 | 640 | } |
| @@ -608,7 +651,7 @@ static void check_ranges_format(struct check *c, struct dt_info *dti, · 10 unmodified lines | ||
| 608 | 651 | return; |
| 609 | 652 | |
| 610 | 653 | if (!node->parent) { |
| 611 | − FAIL(c, "Root node has a \"ranges\" property"); | |
| 654 | + FAIL(c, dti, "Root node has a \"ranges\" property"); | |
| 612 | 655 | return; |
| 613 | 656 | } |
| 614 | 657 | |
| @@ -620,17 +663,17 @@ static void check_ranges_format(struct check *c, struct dt_info *dti, · 5 unmodified lines | ||
| 620 | 663 | |
| 621 | 664 | if (prop->val.len == 0) { |
| 622 | 665 | if (p_addr_cells != c_addr_cells) |
| 623 | − FAIL(c, "%s has empty \"ranges\" property but its " | |
| 666 | + FAIL(c, dti, "%s has empty \"ranges\" property but its " | |
| 624 | 667 | "#address-cells (%d) differs from %s (%d)", |
| 625 | 668 | node->fullpath, c_addr_cells, node->parent->fullpath, |
| 626 | 669 | p_addr_cells); |
| 627 | 670 | if (p_size_cells != c_size_cells) |
| 628 | − FAIL(c, "%s has empty \"ranges\" property but its " | |
| 671 | + FAIL(c, dti, "%s has empty \"ranges\" property but its " | |
| 629 | 672 | "#size-cells (%d) differs from %s (%d)", |
| 630 | 673 | node->fullpath, c_size_cells, node->parent->fullpath, |
| 631 | 674 | p_size_cells); |
| 632 | 675 | } else if ((prop->val.len % entrylen) != 0) { |
| 633 | − FAIL(c, "\"ranges\" property in %s has invalid length (%d bytes) " | |
| 676 | + FAIL(c, dti, "\"ranges\" property in %s has invalid length (%d bytes) " | |
| 634 | 677 | "(parent #address-cells == %d, child #address-cells == %d, " |
| 635 | 678 | "#size-cells == %d)", node->fullpath, prop->val.len, |
| 636 | 679 | p_addr_cells, c_addr_cells, c_size_cells); |
| @@ -638,6 +681,229 @@ static void check_ranges_format(struct check *c, struct dt_info *dti, · 1 unmodified line | ||
| 638 | 681 | } |
| 639 | 682 | WARNING(ranges_format, check_ranges_format, NULL, &addr_size_cells); |
| 640 | 683 | |
| 684 | +static const struct bus_type pci_bus = { | |
| 685 | + .name = "PCI", | |
| 686 | +}; | |
| 687 | + | |
| 688 | +static void check_pci_bridge(struct check *c, struct dt_info *dti, struct node *node) | |
| 689 | +{ | |
| 690 | + struct property *prop; | |
| 691 | + cell_t *cells; | |
| 692 | + | |
| 693 | + prop = get_property(node, "device_type"); | |
| 694 | + if (!prop || !streq(prop->val.val, "pci")) | |
| 695 | + return; | |
| 696 | + | |
| 697 | + node->bus = &pci_bus; | |
| 698 | + | |
| 699 | + if (!strneq(node->name, "pci", node->basenamelen) && | |
| 700 | + !strneq(node->name, "pcie", node->basenamelen)) | |
| 701 | + FAIL(c, dti, "Node %s node name is not \"pci\" or \"pcie\"", | |
| 702 | + node->fullpath); | |
| 703 | + | |
| 704 | + prop = get_property(node, "ranges"); | |
| 705 | + if (!prop) | |
| 706 | + FAIL(c, dti, "Node %s missing ranges for PCI bridge (or not a bridge)", | |
| 707 | + node->fullpath); | |
| 708 | + | |
| 709 | + if (node_addr_cells(node) != 3) | |
| 710 | + FAIL(c, dti, "Node %s incorrect #address-cells for PCI bridge", | |
| 711 | + node->fullpath); | |
| 712 | + if (node_size_cells(node) != 2) | |
| 713 | + FAIL(c, dti, "Node %s incorrect #size-cells for PCI bridge", | |
| 714 | + node->fullpath); | |
| 715 | + | |
| 716 | + prop = get_property(node, "bus-range"); | |
| 717 | + if (!prop) { | |
| 718 | + FAIL(c, dti, "Node %s missing bus-range for PCI bridge", | |
| 719 | + node->fullpath); | |
| 720 | + return; | |
| 721 | + } | |
| 722 | + if (prop->val.len != (sizeof(cell_t) * 2)) { | |
| 723 | + FAIL(c, dti, "Node %s bus-range must be 2 cells", | |
| 724 | + node->fullpath); | |
| 725 | + return; | |
| 726 | + } | |
| 727 | + cells = (cell_t *)prop->val.val; | |
| 728 | + if (fdt32_to_cpu(cells[0]) > fdt32_to_cpu(cells[1])) | |
| 729 | + FAIL(c, dti, "Node %s bus-range 1st cell must be less than or equal to 2nd cell", | |
| 730 | + node->fullpath); | |
| 731 | + if (fdt32_to_cpu(cells[1]) > 0xff) | |
| 732 | + FAIL(c, dti, "Node %s bus-range maximum bus number must be less than 256", | |
| 733 | + node->fullpath); | |
| 734 | +} | |
| 735 | +WARNING(pci_bridge, check_pci_bridge, NULL, | |
| 736 | + &device_type_is_string, &addr_size_cells); | |
| 737 | + | |
| 738 | +static void check_pci_device_bus_num(struct check *c, struct dt_info *dti, struct node *node) | |
| 739 | +{ | |
| 740 | + struct property *prop; | |
| 741 | + unsigned int bus_num, min_bus, max_bus; | |
| 742 | + cell_t *cells; | |
| 743 | + | |
| 744 | + if (!node->parent || (node->parent->bus != &pci_bus)) | |
| 745 | + return; | |
| 746 | + | |
| 747 | + prop = get_property(node, "reg"); | |
| 748 | + if (!prop) | |
| 749 | + return; | |
| 750 | + | |
| 751 | + cells = (cell_t *)prop->val.val; | |
| 752 | + bus_num = (fdt32_to_cpu(cells[0]) & 0x00ff0000) >> 16; | |
| 753 | + | |
| 754 | + prop = get_property(node->parent, "bus-range"); | |
| 755 | + if (!prop) { | |
| 756 | + min_bus = max_bus = 0; | |
| 757 | + } else { | |
| 758 | + cells = (cell_t *)prop->val.val; | |
| 759 | + min_bus = fdt32_to_cpu(cells[0]); | |
| 760 | + max_bus = fdt32_to_cpu(cells[0]); | |
| 761 | + } | |
| 762 | + if ((bus_num < min_bus) || (bus_num > max_bus)) | |
| 763 | + FAIL(c, dti, "Node %s PCI bus number %d out of range, expected (%d - %d)", | |
| 764 | + node->fullpath, bus_num, min_bus, max_bus); | |
| 765 | +} | |
| 766 | +WARNING(pci_device_bus_num, check_pci_device_bus_num, NULL, ®_format, &pci_bridge); | |
| 767 | + | |
| 768 | +static void check_pci_device_reg(struct check *c, struct dt_info *dti, struct node *node) | |
| 769 | +{ | |
| 770 | + struct property *prop; | |
| 771 | + const char *unitname = get_unitname(node); | |
| 772 | + char unit_addr[5]; | |
| 773 | + unsigned int dev, func, reg; | |
| 774 | + cell_t *cells; | |
| 775 | + | |
| 776 | + if (!node->parent || (node->parent->bus != &pci_bus)) | |
| 777 | + return; | |
| 778 | + | |
| 779 | + prop = get_property(node, "reg"); | |
| 780 | + if (!prop) { | |
| 781 | + FAIL(c, dti, "Node %s missing PCI reg property", node->fullpath); | |
| 782 | + return; | |
| 783 | + } | |
| 784 | + | |
| 785 | + cells = (cell_t *)prop->val.val; | |
| 786 | + if (cells[1] || cells[2]) | |
| 787 | + FAIL(c, dti, "Node %s PCI reg config space address cells 2 and 3 must be 0", | |
| 788 | + node->fullpath); | |
| 789 | + | |
| 790 | + reg = fdt32_to_cpu(cells[0]); | |
| 791 | + dev = (reg & 0xf800) >> 11; | |
| 792 | + func = (reg & 0x700) >> 8; | |
| 793 | + | |
| 794 | + if (reg & 0xff000000) | |
| 795 | + FAIL(c, dti, "Node %s PCI reg address is not configuration space", | |
| 796 | + node->fullpath); | |
| 797 | + if (reg & 0x000000ff) | |
| 798 | + FAIL(c, dti, "Node %s PCI reg config space address register number must be 0", | |
| 799 | + node->fullpath); | |
| 800 | + | |
| 801 | + if (func == 0) { | |
| 802 | + snprintf(unit_addr, sizeof(unit_addr), "%x", dev); | |
| 803 | + if (streq(unitname, unit_addr)) | |
| 804 | + return; | |
| 805 | + } | |
| 806 | + | |
| 807 | + snprintf(unit_addr, sizeof(unit_addr), "%x,%x", dev, func); | |
| 808 | + if (streq(unitname, unit_addr)) | |
| 809 | + return; | |
| 810 | + | |
| 811 | + FAIL(c, dti, "Node %s PCI unit address format error, expected \"%s\"", | |
| 812 | + node->fullpath, unit_addr); | |
| 813 | +} | |
| 814 | +WARNING(pci_device_reg, check_pci_device_reg, NULL, ®_format, &pci_bridge); | |
| 815 | + | |
| 816 | +static const struct bus_type simple_bus = { | |
| 817 | + .name = "simple-bus", | |
| 818 | +}; | |
| 819 | + | |
| 820 | +static bool node_is_compatible(struct node *node, const char *compat) | |
| 821 | +{ | |
| 822 | + struct property *prop; | |
| 823 | + const char *str, *end; | |
| 824 | + | |
| 825 | + prop = get_property(node, "compatible"); | |
| 826 | + if (!prop) | |
| 827 | + return false; | |
| 828 | + | |
| 829 | + for (str = prop->val.val, end = str + prop->val.len; str < end; | |
| 830 | + str += strnlen(str, end - str) + 1) { | |
| 831 | + if (strneq(str, compat, end - str)) | |
| 832 | + return true; | |
| 833 | + } | |
| 834 | + return false; | |
| 835 | +} | |
| 836 | + | |
| 837 | +static void check_simple_bus_bridge(struct check *c, struct dt_info *dti, struct node *node) | |
| 838 | +{ | |
| 839 | + if (node_is_compatible(node, "simple-bus")) | |
| 840 | + node->bus = &simple_bus; | |
| 841 | +} | |
| 842 | +WARNING(simple_bus_bridge, check_simple_bus_bridge, NULL, &addr_size_cells); | |
| 843 | + | |
| 844 | +static void check_simple_bus_reg(struct check *c, struct dt_info *dti, struct node *node) | |
| 845 | +{ | |
| 846 | + struct property *prop; | |
| 847 | + const char *unitname = get_unitname(node); | |
| 848 | + char unit_addr[17]; | |
| 849 | + unsigned int size; | |
| 850 | + uint64_t reg = 0; | |
| 851 | + cell_t *cells = NULL; | |
| 852 | + | |
| 853 | + if (!node->parent || (node->parent->bus != &simple_bus)) | |
| 854 | + return; | |
| 855 | + | |
| 856 | + prop = get_property(node, "reg"); | |
| 857 | + if (prop) | |
| 858 | + cells = (cell_t *)prop->val.val; | |
| 859 | + else { | |
| 860 | + prop = get_property(node, "ranges"); | |
| 861 | + if (prop && prop->val.len) | |
| 862 | + /* skip of child address */ | |
| 863 | + cells = ((cell_t *)prop->val.val) + node_addr_cells(node); | |
| 864 | + } | |
| 865 | + | |
| 866 | + if (!cells) { | |
| 867 | + if (node->parent->parent && !(node->bus == &simple_bus)) | |
| 868 | + FAIL(c, dti, "Node %s missing or empty reg/ranges property", node->fullpath); | |
| 869 | + return; | |
| 870 | + } | |
| 871 | + | |
| 872 | + size = node_addr_cells(node->parent); | |
| 873 | + while (size--) | |
| 874 | + reg = (reg << 32) | fdt32_to_cpu(*(cells++)); | |
| 875 | + | |
| 876 | + snprintf(unit_addr, sizeof(unit_addr), "%lx", reg); | |
| 877 | + if (!streq(unitname, unit_addr)) | |
| 878 | + FAIL(c, dti, "Node %s simple-bus unit address format error, expected \"%s\"", | |
| 879 | + node->fullpath, unit_addr); | |
| 880 | +} | |
| 881 | +WARNING(simple_bus_reg, check_simple_bus_reg, NULL, ®_format, &simple_bus_bridge); | |
| 882 | + | |
| 883 | +static void check_unit_address_format(struct check *c, struct dt_info *dti, | |
| 884 | + struct node *node) | |
| 885 | +{ | |
| 886 | + const char *unitname = get_unitname(node); | |
| 887 | + | |
| 888 | + if (node->parent && node->parent->bus) | |
| 889 | + return; | |
| 890 | + | |
| 891 | + if (!unitname[0]) | |
| 892 | + return; | |
| 893 | + | |
| 894 | + if (!strncmp(unitname, "0x", 2)) { | |
| 895 | + FAIL(c, dti, "Node %s unit name should not have leading \"0x\"", | |
| 896 | + node->fullpath); | |
| 897 | + /* skip over 0x for next test */ | |
| 898 | + unitname += 2; | |
| 899 | + } | |
| 900 | + if (unitname[0] == '0' && isxdigit(unitname[1])) | |
| 901 | + FAIL(c, dti, "Node %s unit name should not have leading 0s", | |
| 902 | + node->fullpath); | |
| 903 | +} | |
| 904 | +WARNING(unit_address_format, check_unit_address_format, NULL, | |
| 905 | + &node_name_format, &pci_bridge, &simple_bus_bridge); | |
| 906 | + | |
| 641 | 907 | /* |
| 642 | 908 | * Style checks |
| 643 | 909 | */ |
| @@ -656,11 +922,11 @@ static void check_avoid_default_addr_size(struct check *c, struct dt_info *dti, · 12 unmodified lines | ||
| 656 | 922 | return; |
| 657 | 923 | |
| 658 | 924 | if (node->parent->addr_cells == -1) |
| 659 | − FAIL(c, "Relying on default #address-cells value for %s", | |
| 925 | + FAIL(c, dti, "Relying on default #address-cells value for %s", | |
| 660 | 926 | node->fullpath); |
| 661 | 927 | |
| 662 | 928 | if (node->parent->size_cells == -1) |
| 663 | − FAIL(c, "Relying on default #size-cells value for %s", | |
| 929 | + FAIL(c, dti, "Relying on default #size-cells value for %s", | |
| 664 | 930 | node->fullpath); |
| 665 | 931 | } |
| 666 | 932 | WARNING(avoid_default_addr_size, check_avoid_default_addr_size, NULL, |
| @@ -684,7 +950,7 @@ static void check_obsolete_chosen_interrupt_controller(struct check *c, · 17 unmodified lines | ||
| 684 | 950 | |
| 685 | 951 | prop = get_property(chosen, "interrupt-controller"); |
| 686 | 952 | if (prop) |
| 687 | − FAIL(c, "/chosen has obsolete \"interrupt-controller\" " | |
| 953 | + FAIL(c, dti, "/chosen has obsolete \"interrupt-controller\" " | |
| 688 | 954 | "property"); |
| 689 | 955 | } |
| 690 | 956 | WARNING(obsolete_chosen_interrupt_controller, |
| @@ -703,9 +969,20 @@ static struct check *check_table[] = { · 12 unmodified lines | ||
| 703 | 969 | &address_cells_is_cell, &size_cells_is_cell, &interrupt_cells_is_cell, |
| 704 | 970 | &device_type_is_string, &model_is_string, &status_is_string, |
| 705 | 971 | |
| 972 | + &property_name_chars_strict, | |
| 973 | + &node_name_chars_strict, | |
| 974 | + | |
| 706 | 975 | &addr_size_cells, ®_format, &ranges_format, |
| 707 | 976 | |
| 708 | 977 | &unit_address_vs_reg, |
| 978 | + &unit_address_format, | |
| 979 | + | |
| 980 | + &pci_bridge, | |
| 981 | + &pci_device_reg, | |
| 982 | + &pci_device_bus_num, | |
| 983 | + | |
| 984 | + &simple_bus_bridge, | |
| 985 | + &simple_bus_reg, | |
| 709 | 986 | |
| 710 | 987 | &avoid_default_addr_size, |
| 711 | 988 | &obsolete_chosen_interrupt_controller, |
| @@ -171,9 +171,9 @@ struct data data_merge(struct data d1, struct data d2) · 170 unmodified lines | ||
| 171 | 171 | struct data data_append_integer(struct data d, uint64_t value, int bits) |
| 172 | 172 | { |
| 173 | 173 | uint8_t value_8; |
| 174 | − uint16_t value_16; | |
| 175 | − uint32_t value_32; | |
| 176 | − uint64_t value_64; | |
| 174 | + fdt16_t value_16; | |
| 175 | + fdt32_t value_32; | |
| 176 | + fdt64_t value_64; | |
| 177 | 177 | |
| 178 | 178 | switch (bits) { |
| 179 | 179 | case 8: |
| @@ -197,14 +197,14 @@ struct data data_append_integer(struct data d, uint64_t value, int bits) · 17 unmodified lines | ||
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | −struct data data_append_re(struct data d, const struct fdt_reserve_entry *re) | |
| 200 | +struct data data_append_re(struct data d, uint64_t address, uint64_t size) | |
| 201 | 201 | { |
| 202 | − struct fdt_reserve_entry bere; | |
| 202 | + struct fdt_reserve_entry re; | |
| 203 | 203 | |
| 204 | − bere.address = cpu_to_fdt64(re->address); | |
| 205 | − bere.size = cpu_to_fdt64(re->size); | |
| 204 | + re.address = cpu_to_fdt64(address); | |
| 205 | + re.size = cpu_to_fdt64(size); | |
| 206 | 206 | |
| 207 | − return data_append_data(d, &bere, sizeof(bere)); | |
| 207 | + return data_append_data(d, &re, sizeof(re)); | |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | struct data data_append_cell(struct data d, cell_t word) |
| @@ -62,7 +62,8 @@ static int dts_version = 1; · 61 unmodified lines | ||
| 62 | 62 | |
| 63 | 63 | static void push_input_file(const char *filename); |
| 64 | 64 | static bool pop_input_file(void); |
| 65 | −static void lexical_error(const char *fmt, ...); | |
| 65 | +static void PRINTF(1, 2) lexical_error(const char *fmt, ...); | |
| 66 | + | |
| 66 | 67 | %} |
| 67 | 68 | |
| 68 | 69 | %% |
| @@ -655,8 +655,9 @@ static int dts_version = 1; · 654 unmodified lines | ||
| 655 | 655 | |
| 656 | 656 | static void push_input_file(const char *filename); |
| 657 | 657 | static bool pop_input_file(void); |
| 658 | −static void lexical_error(const char *fmt, ...); | |
| 659 | −#line 660 "dtc-lexer.lex.c" | |
| 658 | +static void PRINTF(1, 2) lexical_error(const char *fmt, ...); | |
| 659 | + | |
| 660 | +#line 661 "dtc-lexer.lex.c" | |
| 660 | 661 | |
| 661 | 662 | #define INITIAL 0 |
| 662 | 663 | #define BYTESTRING 1 |
| @@ -878,9 +879,9 @@ YY_DECL · 215 unmodified lines | ||
| 878 | 879 | } |
| 879 | 880 | |
| 880 | 881 | { |
| 881 | −#line 68 "dtc-lexer.l" | |
| 882 | +#line 69 "dtc-lexer.l" | |
| 882 | 883 | |
| 883 | −#line 884 "dtc-lexer.lex.c" | |
| 884 | +#line 885 "dtc-lexer.lex.c" | |
| 884 | 885 | |
| 885 | 886 | while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ |
| 886 | 887 | { |
| @@ -937,7 +938,7 @@ do_action: /* This label is used only to access EOF actions. */ · 50 unmodified lines | ||
| 937 | 938 | case 1: |
| 938 | 939 | /* rule 1 can match eol */ |
| 939 | 940 | YY_RULE_SETUP |
| 940 | −#line 69 "dtc-lexer.l" | |
| 941 | +#line 70 "dtc-lexer.l" | |
| 941 | 942 | { |
| 942 | 943 | char *name = strchr(yytext, '\"') + 1; |
| 943 | 944 | yytext[yyleng-1] = '\0'; |
| @@ -947,7 +948,7 @@ YY_RULE_SETUP · 3 unmodified lines | ||
| 947 | 948 | case 2: |
| 948 | 949 | /* rule 2 can match eol */ |
| 949 | 950 | YY_RULE_SETUP |
| 950 | −#line 75 "dtc-lexer.l" | |
| 951 | +#line 76 "dtc-lexer.l" | |
| 951 | 952 | { |
| 952 | 953 | char *line, *fnstart, *fnend; |
| 953 | 954 | struct data fn; |
| @@ -981,7 +982,7 @@ case YY_STATE_EOF(INITIAL): · 27 unmodified lines | ||
| 981 | 982 | case YY_STATE_EOF(BYTESTRING): |
| 982 | 983 | case YY_STATE_EOF(PROPNODENAME): |
| 983 | 984 | case YY_STATE_EOF(V1): |
| 984 | −#line 104 "dtc-lexer.l" | |
| 985 | +#line 105 "dtc-lexer.l" | |
| 985 | 986 | { |
| 986 | 987 | if (!pop_input_file()) { |
| 987 | 988 | yyterminate(); |
| @@ -991,7 +992,7 @@ case YY_STATE_EOF(V1): · 3 unmodified lines | ||
| 991 | 992 | case 3: |
| 992 | 993 | /* rule 3 can match eol */ |
| 993 | 994 | YY_RULE_SETUP |
| 994 | −#line 110 "dtc-lexer.l" | |
| 995 | +#line 111 "dtc-lexer.l" | |
| 995 | 996 | { |
| 996 | 997 | DPRINT("String: %s\n", yytext); |
| 997 | 998 | yylval.data = data_copy_escape_string(yytext+1, |
| @@ -1001,7 +1002,7 @@ YY_RULE_SETUP · 3 unmodified lines | ||
| 1001 | 1002 | YY_BREAK |
| 1002 | 1003 | case 4: |
| 1003 | 1004 | YY_RULE_SETUP |
| 1004 | −#line 117 "dtc-lexer.l" | |
| 1005 | +#line 118 "dtc-lexer.l" | |
| 1005 | 1006 | { |
| 1006 | 1007 | DPRINT("Keyword: /dts-v1/\n"); |
| 1007 | 1008 | dts_version = 1; |
| @@ -1011,7 +1012,7 @@ YY_RULE_SETUP · 3 unmodified lines | ||
| 1011 | 1012 | YY_BREAK |
| 1012 | 1013 | case 5: |
| 1013 | 1014 | YY_RULE_SETUP |
| 1014 | −#line 124 "dtc-lexer.l" | |
| 1015 | +#line 125 "dtc-lexer.l" | |
| 1015 | 1016 | { |
| 1016 | 1017 | DPRINT("Keyword: /plugin/\n"); |
| 1017 | 1018 | return DT_PLUGIN; |
| @@ -1019,7 +1020,7 @@ YY_RULE_SETUP · 1 unmodified line | ||
| 1019 | 1020 | YY_BREAK |
| 1020 | 1021 | case 6: |
| 1021 | 1022 | YY_RULE_SETUP |
| 1022 | −#line 129 "dtc-lexer.l" | |
| 1023 | +#line 130 "dtc-lexer.l" | |
| 1023 | 1024 | { |
| 1024 | 1025 | DPRINT("Keyword: /memreserve/\n"); |
| 1025 | 1026 | BEGIN_DEFAULT(); |
| @@ -1028,7 +1029,7 @@ YY_RULE_SETUP · 2 unmodified lines | ||
| 1028 | 1029 | YY_BREAK |
| 1029 | 1030 | case 7: |
| 1030 | 1031 | YY_RULE_SETUP |
| 1031 | −#line 135 "dtc-lexer.l" | |
| 1032 | +#line 136 "dtc-lexer.l" | |
| 1032 | 1033 | { |
| 1033 | 1034 | DPRINT("Keyword: /bits/\n"); |
| 1034 | 1035 | BEGIN_DEFAULT(); |
| @@ -1037,7 +1038,7 @@ YY_RULE_SETUP · 2 unmodified lines | ||
| 1037 | 1038 | YY_BREAK |
| 1038 | 1039 | case 8: |
| 1039 | 1040 | YY_RULE_SETUP |
| 1040 | −#line 141 "dtc-lexer.l" | |
| 1041 | +#line 142 "dtc-lexer.l" | |
| 1041 | 1042 | { |
| 1042 | 1043 | DPRINT("Keyword: /delete-property/\n"); |
| 1043 | 1044 | DPRINT("<PROPNODENAME>\n"); |
| @@ -1047,7 +1048,7 @@ YY_RULE_SETUP · 3 unmodified lines | ||
| 1047 | 1048 | YY_BREAK |
| 1048 | 1049 | case 9: |
| 1049 | 1050 | YY_RULE_SETUP |
| 1050 | −#line 148 "dtc-lexer.l" | |
| 1051 | +#line 149 "dtc-lexer.l" | |
| 1051 | 1052 | { |
| 1052 | 1053 | DPRINT("Keyword: /delete-node/\n"); |
| 1053 | 1054 | DPRINT("<PROPNODENAME>\n"); |
| @@ -1057,7 +1058,7 @@ YY_RULE_SETUP · 3 unmodified lines | ||
| 1057 | 1058 | YY_BREAK |
| 1058 | 1059 | case 10: |
| 1059 | 1060 | YY_RULE_SETUP |
| 1060 | −#line 155 "dtc-lexer.l" | |
| 1061 | +#line 156 "dtc-lexer.l" | |
| 1061 | 1062 | { |
| 1062 | 1063 | DPRINT("Label: %s\n", yytext); |
| 1063 | 1064 | yylval.labelref = xstrdup(yytext); |
| @@ -1067,7 +1068,7 @@ YY_RULE_SETUP · 3 unmodified lines | ||
| 1067 | 1068 | YY_BREAK |
| 1068 | 1069 | case 11: |
| 1069 | 1070 | YY_RULE_SETUP |
| 1070 | −#line 162 "dtc-lexer.l" | |
| 1071 | +#line 163 "dtc-lexer.l" | |
| 1071 | 1072 | { |
| 1072 | 1073 | char *e; |
| 1073 | 1074 | DPRINT("Integer Literal: '%s'\n", yytext); |
| @@ -1093,7 +1094,7 @@ YY_RULE_SETUP · 19 unmodified lines | ||
| 1093 | 1094 | case 12: |
| 1094 | 1095 | /* rule 12 can match eol */ |
| 1095 | 1096 | YY_RULE_SETUP |
| 1096 | −#line 184 "dtc-lexer.l" | |
| 1097 | +#line 185 "dtc-lexer.l" | |
| 1097 | 1098 | { |
| 1098 | 1099 | struct data d; |
| 1099 | 1100 | DPRINT("Character literal: %s\n", yytext); |
| @@ -1117,7 +1118,7 @@ YY_RULE_SETUP · 17 unmodified lines | ||
| 1117 | 1118 | YY_BREAK |
| 1118 | 1119 | case 13: |
| 1119 | 1120 | YY_RULE_SETUP |
| 1120 | −#line 205 "dtc-lexer.l" | |
| 1121 | +#line 206 "dtc-lexer.l" | |
| 1121 | 1122 | { /* label reference */ |
| 1122 | 1123 | DPRINT("Ref: %s\n", yytext+1); |
| 1123 | 1124 | yylval.labelref = xstrdup(yytext+1); |
| @@ -1126,7 +1127,7 @@ YY_RULE_SETUP · 2 unmodified lines | ||
| 1126 | 1127 | YY_BREAK |
| 1127 | 1128 | case 14: |
| 1128 | 1129 | YY_RULE_SETUP |
| 1129 | −#line 211 "dtc-lexer.l" | |
| 1130 | +#line 212 "dtc-lexer.l" | |
| 1130 | 1131 | { /* new-style path reference */ |
| 1131 | 1132 | yytext[yyleng-1] = '\0'; |
| 1132 | 1133 | DPRINT("Ref: %s\n", yytext+2); |
| @@ -1136,7 +1137,7 @@ YY_RULE_SETUP · 3 unmodified lines | ||
| 1136 | 1137 | YY_BREAK |
| 1137 | 1138 | case 15: |
| 1138 | 1139 | YY_RULE_SETUP |
| 1139 | −#line 218 "dtc-lexer.l" | |
| 1140 | +#line 219 "dtc-lexer.l" | |
| 1140 | 1141 | { |
| 1141 | 1142 | yylval.byte = strtol(yytext, NULL, 16); |
| 1142 | 1143 | DPRINT("Byte: %02x\n", (int)yylval.byte); |
| @@ -1145,7 +1146,7 @@ YY_RULE_SETUP · 2 unmodified lines | ||
| 1145 | 1146 | YY_BREAK |
| 1146 | 1147 | case 16: |
| 1147 | 1148 | YY_RULE_SETUP |
| 1148 | −#line 224 "dtc-lexer.l" | |
| 1149 | +#line 225 "dtc-lexer.l" | |
| 1149 | 1150 | { |
| 1150 | 1151 | DPRINT("/BYTESTRING\n"); |
| 1151 | 1152 | BEGIN_DEFAULT(); |
| @@ -1154,7 +1155,7 @@ YY_RULE_SETUP · 2 unmodified lines | ||
| 1154 | 1155 | YY_BREAK |
| 1155 | 1156 | case 17: |
| 1156 | 1157 | YY_RULE_SETUP |
| 1157 | −#line 230 "dtc-lexer.l" | |
| 1158 | +#line 231 "dtc-lexer.l" | |
| 1158 | 1159 | { |
| 1159 | 1160 | DPRINT("PropNodeName: %s\n", yytext); |
| 1160 | 1161 | yylval.propnodename = xstrdup((yytext[0] == '\\') ? |
| @@ -1165,7 +1166,7 @@ YY_RULE_SETUP · 4 unmodified lines | ||
| 1165 | 1166 | YY_BREAK |
| 1166 | 1167 | case 18: |
| 1167 | 1168 | YY_RULE_SETUP |
| 1168 | −#line 238 "dtc-lexer.l" | |
| 1169 | +#line 239 "dtc-lexer.l" | |
| 1169 | 1170 | { |
| 1170 | 1171 | DPRINT("Binary Include\n"); |
| 1171 | 1172 | return DT_INCBIN; |
| @@ -1174,64 +1175,64 @@ YY_RULE_SETUP · 2 unmodified lines | ||
| 1174 | 1175 | case 19: |
| 1175 | 1176 | /* rule 19 can match eol */ |
| 1176 | 1177 | YY_RULE_SETUP |
| 1177 | −#line 243 "dtc-lexer.l" | |
| 1178 | +#line 244 "dtc-lexer.l" | |
| 1178 | 1179 | /* eat whitespace */ |
| 1179 | 1180 | YY_BREAK |
| 1180 | 1181 | case 20: |
| 1181 | 1182 | /* rule 20 can match eol */ |
| 1182 | 1183 | YY_RULE_SETUP |
| 1183 | −#line 244 "dtc-lexer.l" | |
| 1184 | +#line 245 "dtc-lexer.l" | |
| 1184 | 1185 | /* eat C-style comments */ |
| 1185 | 1186 | YY_BREAK |
| 1186 | 1187 | case 21: |
| 1187 | 1188 | /* rule 21 can match eol */ |
| 1188 | 1189 | YY_RULE_SETUP |
| 1189 | −#line 245 "dtc-lexer.l" | |
| 1190 | +#line 246 "dtc-lexer.l" | |
| 1190 | 1191 | /* eat C++-style comments */ |
| 1191 | 1192 | YY_BREAK |
| 1192 | 1193 | case 22: |
| 1193 | 1194 | YY_RULE_SETUP |
| 1194 | −#line 247 "dtc-lexer.l" | |
| 1195 | +#line 248 "dtc-lexer.l" | |
| 1195 | 1196 | { return DT_LSHIFT; }; |
| 1196 | 1197 | YY_BREAK |
| 1197 | 1198 | case 23: |
| 1198 | 1199 | YY_RULE_SETUP |
| 1199 | −#line 248 "dtc-lexer.l" | |
| 1200 | +#line 249 "dtc-lexer.l" | |
| 1200 | 1201 | { return DT_RSHIFT; }; |
| 1201 | 1202 | YY_BREAK |
| 1202 | 1203 | case 24: |
| 1203 | 1204 | YY_RULE_SETUP |
| 1204 | −#line 249 "dtc-lexer.l" | |
| 1205 | +#line 250 "dtc-lexer.l" | |
| 1205 | 1206 | { return DT_LE; }; |
| 1206 | 1207 | YY_BREAK |
| 1207 | 1208 | case 25: |
| 1208 | 1209 | YY_RULE_SETUP |
| 1209 | −#line 250 "dtc-lexer.l" | |
| 1210 | +#line 251 "dtc-lexer.l" | |
| 1210 | 1211 | { return DT_GE; }; |
| 1211 | 1212 | YY_BREAK |
| 1212 | 1213 | case 26: |
| 1213 | 1214 | YY_RULE_SETUP |
| 1214 | −#line 251 "dtc-lexer.l" | |
| 1215 | +#line 252 "dtc-lexer.l" | |
| 1215 | 1216 | { return DT_EQ; }; |
| 1216 | 1217 | YY_BREAK |
| 1217 | 1218 | case 27: |
| 1218 | 1219 | YY_RULE_SETUP |
| 1219 | −#line 252 "dtc-lexer.l" | |
| 1220 | +#line 253 "dtc-lexer.l" | |
| 1220 | 1221 | { return DT_NE; }; |
| 1221 | 1222 | YY_BREAK |
| 1222 | 1223 | case 28: |
| 1223 | 1224 | YY_RULE_SETUP |
| 1224 | −#line 253 "dtc-lexer.l" | |
| 1225 | +#line 254 "dtc-lexer.l" | |
| 1225 | 1226 | { return DT_AND; }; |
| 1226 | 1227 | YY_BREAK |
| 1227 | 1228 | case 29: |
| 1228 | 1229 | YY_RULE_SETUP |
| 1229 | −#line 254 "dtc-lexer.l" | |
| 1230 | +#line 255 "dtc-lexer.l" | |
| 1230 | 1231 | { return DT_OR; }; |
| 1231 | 1232 | YY_BREAK |
| 1232 | 1233 | case 30: |
| 1233 | 1234 | YY_RULE_SETUP |
| 1234 | −#line 256 "dtc-lexer.l" | |
| 1235 | +#line 257 "dtc-lexer.l" | |
| 1235 | 1236 | { |
| 1236 | 1237 | DPRINT("Char: %c (\\x%02x)\n", yytext[0], |
| 1237 | 1238 | (unsigned)yytext[0]); |
| @@ -1249,10 +1250,10 @@ YY_RULE_SETUP · 11 unmodified lines | ||
| 1249 | 1250 | YY_BREAK |
| 1250 | 1251 | case 31: |
| 1251 | 1252 | YY_RULE_SETUP |
| 1252 | −#line 271 "dtc-lexer.l" | |
| 1253 | +#line 272 "dtc-lexer.l" | |
| 1253 | 1254 | ECHO; |
| 1254 | 1255 | YY_BREAK |
| 1255 | −#line 1256 "dtc-lexer.lex.c" | |
| 1256 | +#line 1257 "dtc-lexer.lex.c" | |
| 1256 | 1257 | |
| 1257 | 1258 | case YY_END_OF_BUFFER: |
| 1258 | 1259 | { |
| @@ -2218,7 +2219,7 @@ void yyfree (void * ptr ) · 959 unmodified lines | ||
| 2218 | 2219 | |
| 2219 | 2220 | #define YYTABLES_NAME "yytables" |
| 2220 | 2221 | |
| 2221 | −#line 271 "dtc-lexer.l" | |
| 2222 | +#line 272 "dtc-lexer.l" | |
| 2222 | 2223 | |
| 2223 | 2224 | |
| 2224 | 2225 | |
| @@ -1557,10 +1557,10 @@ yyreduce: · 1556 unmodified lines | ||
| 1557 | 1557 | { |
| 1558 | 1558 | struct node *target = get_node_by_ref((yyvsp[-3].node), (yyvsp[-1].labelref)); |
| 1559 | 1559 | |
| 1560 | − add_label(&target->labels, (yyvsp[-2].labelref)); | |
| 1561 | − if (target) | |
| 1560 | + if (target) { | |
| 1561 | + add_label(&target->labels, (yyvsp[-2].labelref)); | |
| 1562 | 1562 | merge_nodes(target, (yyvsp[0].node)); |
| 1563 | − else | |
| 1563 | + } else | |
| 1564 | 1564 | ERROR(&(yylsp[-1]), "Label or path %s not found", (yyvsp[-1].labelref)); |
| 1565 | 1565 | (yyval.node) = (yyvsp[-3].node); |
| 1566 | 1566 | } |
| @@ -171,10 +171,10 @@ devicetree: · 170 unmodified lines | ||
| 171 | 171 | { |
| 172 | 172 | struct node *target = get_node_by_ref($1, $3); |
| 173 | 173 | |
| 174 | − add_label(&target->labels, $2); | |
| 175 | − if (target) | |
| 174 | + if (target) { | |
| 175 | + add_label(&target->labels, $2); | |
| 176 | 176 | merge_nodes(target, $4); |
| 177 | − else | |
| 177 | + } else | |
| 178 | 178 | ERROR(&@3, "Label or path %s not found", $3); |
| 179 | 179 | $$ = $1; |
| 180 | 180 | } |
| @@ -138,7 +138,7 @@ static const char *guess_type_by_name(const char *fname, const char *fallback) · 137 unmodified lines | ||
| 138 | 138 | static const char *guess_input_format(const char *fname, const char *fallback) |
| 139 | 139 | { |
| 140 | 140 | struct stat statbuf; |
| 141 | − uint32_t magic; | |
| 141 | + fdt32_t magic; | |
| 142 | 142 | FILE *f; |
| 143 | 143 | |
| 144 | 144 | if (stat(fname, &statbuf) != 0) |
| @@ -159,8 +159,7 @@ static const char *guess_input_format(const char *fname, const char *fallback) · 14 unmodified lines | ||
| 159 | 159 | } |
| 160 | 160 | fclose(f); |
| 161 | 161 | |
| 162 | − magic = fdt32_to_cpu(magic); | |
| 163 | − if (magic == FDT_MAGIC) | |
| 162 | + if (fdt32_to_cpu(magic) == FDT_MAGIC) | |
| 164 | 163 | return "dtb"; |
| 165 | 164 | |
| 166 | 165 | return guess_type_by_name(fname, fallback); |
| @@ -216,7 +215,7 @@ int main(int argc, char *argv[]) · 49 unmodified lines | ||
| 216 | 215 | alignsize = strtol(optarg, NULL, 0); |
| 217 | 216 | if (!is_power_of_2(alignsize)) |
| 218 | 217 | die("Invalid argument \"%d\" to -a option\n", |
| 219 | − optarg); | |
| 218 | + alignsize); | |
| 220 | 219 | break; |
| 221 | 220 | case 'f': |
| 222 | 221 | force = true; |
| @@ -309,6 +308,8 @@ int main(int argc, char *argv[]) · 86 unmodified lines | ||
| 309 | 308 | else |
| 310 | 309 | die("Unknown input format \"%s\"\n", inform); |
| 311 | 310 | |
| 311 | + dti->outname = outname; | |
| 312 | + | |
| 312 | 313 | if (depfile) { |
| 313 | 314 | fputc('\n', depfile); |
| 314 | 315 | fclose(depfile); |
| @@ -43,7 +43,6 @@ · 42 unmodified lines | ||
| 43 | 43 | #define debug(...) |
| 44 | 44 | #endif |
| 45 | 45 | |
| 46 | − | |
| 47 | 46 | #define DEFAULT_FDT_VERSION 17 |
| 48 | 47 | |
| 49 | 48 | /* |
| @@ -114,7 +113,7 @@ struct data data_insert_at_marker(struct data d, struct marker *m, · 64 unmodified lines | ||
| 114 | 113 | struct data data_merge(struct data d1, struct data d2); |
| 115 | 114 | struct data data_append_cell(struct data d, cell_t word); |
| 116 | 115 | struct data data_append_integer(struct data d, uint64_t word, int bits); |
| 117 | −struct data data_append_re(struct data d, const struct fdt_reserve_entry *re); | |
| 116 | +struct data data_append_re(struct data d, uint64_t address, uint64_t size); | |
| 118 | 117 | struct data data_append_addr(struct data d, uint64_t addr); |
| 119 | 118 | struct data data_append_byte(struct data d, uint8_t byte); |
| 120 | 119 | struct data data_append_zeroes(struct data d, int len); |
| @@ -136,6 +135,10 @@ struct label { · 15 unmodified lines | ||
| 136 | 135 | struct label *next; |
| 137 | 136 | }; |
| 138 | 137 | |
| 138 | +struct bus_type { | |
| 139 | + const char *name; | |
| 140 | +}; | |
| 141 | + | |
| 139 | 142 | struct property { |
| 140 | 143 | bool deleted; |
| 141 | 144 | char *name; |
| @@ -162,6 +165,7 @@ struct node { · 20 unmodified lines | ||
| 162 | 165 | int addr_cells, size_cells; |
| 163 | 166 | |
| 164 | 167 | struct label *labels; |
| 168 | + const struct bus_type *bus; | |
| 165 | 169 | }; |
| 166 | 170 | |
| 167 | 171 | #define for_each_label_withdel(l0, l) \ |
| @@ -227,7 +231,7 @@ uint32_t guess_boot_cpuid(struct node *tree); · 59 unmodified lines | ||
| 227 | 231 | /* Boot info (tree plus memreserve information */ |
| 228 | 232 | |
| 229 | 233 | struct reserve_info { |
| 230 | − struct fdt_reserve_entry re; | |
| 234 | + uint64_t address, size; | |
| 231 | 235 | |
| 232 | 236 | struct reserve_info *next; |
| 233 | 237 | |
| @@ -246,6 +250,7 @@ struct dt_info { · 12 unmodified lines | ||
| 246 | 250 | struct reserve_info *reservelist; |
| 247 | 251 | uint32_t boot_cpuid_phys; |
| 248 | 252 | struct node *dt; /* the device tree */ |
| 253 | + const char *outname; /* filename being written to, "-" for stdout */ | |
| 249 | 254 | }; |
| 250 | 255 | |
| 251 | 256 | /* DTS version flags definitions */ |
| @@ -49,7 +49,7 @@ static struct version_info { · 48 unmodified lines | ||
| 49 | 49 | |
| 50 | 50 | struct emitter { |
| 51 | 51 | void (*cell)(void *, cell_t); |
| 52 | − void (*string)(void *, char *, int); | |
| 52 | + void (*string)(void *, const char *, int); | |
| 53 | 53 | void (*align)(void *, int); |
| 54 | 54 | void (*data)(void *, struct data); |
| 55 | 55 | void (*beginnode)(void *, struct label *labels); |
| @@ -64,7 +64,7 @@ static void bin_emit_cell(void *e, cell_t val) · 8 unmodified lines | ||
| 64 | 64 | *dtbuf = data_append_cell(*dtbuf, val); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | −static void bin_emit_string(void *e, char *str, int len) | |
| 67 | +static void bin_emit_string(void *e, const char *str, int len) | |
| 68 | 68 | { |
| 69 | 69 | struct data *dtbuf = e; |
| 70 | 70 | |
| @@ -144,22 +144,14 @@ static void asm_emit_cell(void *e, cell_t val) · 73 unmodified lines | ||
| 144 | 144 | (val >> 8) & 0xff, val & 0xff); |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | −static void asm_emit_string(void *e, char *str, int len) | |
| 147 | +static void asm_emit_string(void *e, const char *str, int len) | |
| 148 | 148 | { |
| 149 | 149 | FILE *f = e; |
| 150 | − char c = 0; | |
| 151 | 150 | |
| 152 | − if (len != 0) { | |
| 153 | − /* XXX: ewww */ | |
| 154 | − c = str[len]; | |
| 155 | − str[len] = '\0'; | |
| 156 | − } | |
| 157 | − | |
| 158 | − fprintf(f, "\t.string\t\"%s\"\n", str); | |
| 159 | − | |
| 160 | − if (len != 0) { | |
| 161 | − str[len] = c; | |
| 162 | − } | |
| 151 | + if (len != 0) | |
| 152 | + fprintf(f, "\t.string\t\"%.*s\"\n", len, str); | |
| 153 | + else | |
| 154 | + fprintf(f, "\t.string\t\"%s\"\n", str); | |
| 163 | 155 | } |
| 164 | 156 | |
| 165 | 157 | static void asm_emit_align(void *e, int a) |
| @@ -179,7 +171,7 @@ static void asm_emit_data(void *e, struct data d) · 13 unmodified lines | ||
| 179 | 171 | emit_offset_label(f, m->ref, m->offset); |
| 180 | 172 | |
| 181 | 173 | while ((d.len - off) >= sizeof(uint32_t)) { |
| 182 | − asm_emit_cell(e, fdt32_to_cpu(*((uint32_t *)(d.val+off)))); | |
| 174 | + asm_emit_cell(e, fdt32_to_cpu(*((fdt32_t *)(d.val+off)))); | |
| 183 | 175 | off += sizeof(uint32_t); |
| 184 | 176 | } |
| 185 | 177 | |
| @@ -318,17 +310,16 @@ static struct data flatten_reserve_list(struct reserve_info *reservelist, · 132 unmodified lines | ||
| 318 | 310 | { |
| 319 | 311 | struct reserve_info *re; |
| 320 | 312 | struct data d = empty_data; |
| 321 | − static struct fdt_reserve_entry null_re = {0,0}; | |
| 322 | 313 | int j; |
| 323 | 314 | |
| 324 | 315 | for (re = reservelist; re; re = re->next) { |
| 325 | − d = data_append_re(d, &re->re); | |
| 316 | + d = data_append_re(d, re->address, re->size); | |
| 326 | 317 | } |
| 327 | 318 | /* |
| 328 | 319 | * Add additional reserved slots if the user asked for them. |
| 329 | 320 | */ |
| 330 | 321 | for (j = 0; j < reservenum; j++) { |
| 331 | − d = data_append_re(d, &null_re); | |
| 322 | + d = data_append_re(d, 0, 0); | |
| 332 | 323 | } |
| 333 | 324 | |
| 334 | 325 | return d; |
| @@ -544,11 +535,11 @@ void dt_to_asm(FILE *f, struct dt_info *dti, int version) · 209 unmodified lines | ||
| 544 | 535 | fprintf(f, "\t.globl\t%s\n", l->label); |
| 545 | 536 | fprintf(f, "%s:\n", l->label); |
| 546 | 537 | } |
| 547 | − ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.address >> 32)); | |
| 538 | + ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->address >> 32)); | |
| 548 | 539 | ASM_EMIT_BELONG(f, "0x%08x", |
| 549 | − (unsigned int)(re->re.address & 0xffffffff)); | |
| 550 | − ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.size >> 32)); | |
| 551 | − ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->re.size & 0xffffffff)); | |
| 540 | + (unsigned int)(re->address & 0xffffffff)); | |
| 541 | + ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->size >> 32)); | |
| 542 | + ASM_EMIT_BELONG(f, "0x%08x", (unsigned int)(re->size & 0xffffffff)); | |
| 552 | 543 | } |
| 553 | 544 | for (i = 0; i < reservenum; i++) { |
| 554 | 545 | fprintf(f, "\t.long\t0, 0\n\t.long\t0, 0\n"); |
| @@ -609,7 +600,7 @@ static void flat_read_chunk(struct inbuf *inb, void *p, int len) · 54 unmodified lines | ||
| 609 | 600 | |
| 610 | 601 | static uint32_t flat_read_word(struct inbuf *inb) |
| 611 | 602 | { |
| 612 | − uint32_t val; | |
| 603 | + fdt32_t val; | |
| 613 | 604 | |
| 614 | 605 | assert(((inb->ptr - inb->base) % sizeof(val)) == 0); |
| 615 | 606 | |
| @@ -718,13 +709,15 @@ static struct reserve_info *flat_read_mem_reserve(struct inbuf *inb) · 102 unmodified lines | ||
| 718 | 709 | * First pass, count entries. |
| 719 | 710 | */ |
| 720 | 711 | while (1) { |
| 712 | + uint64_t address, size; | |
| 713 | + | |
| 721 | 714 | flat_read_chunk(inb, &re, sizeof(re)); |
| 722 | − re.address = fdt64_to_cpu(re.address); | |
| 723 | − re.size = fdt64_to_cpu(re.size); | |
| 724 | − if (re.size == 0) | |
| 715 | + address = fdt64_to_cpu(re.address); | |
| 716 | + size = fdt64_to_cpu(re.size); | |
| 717 | + if (size == 0) | |
| 725 | 718 | break; |
| 726 | 719 | |
| 727 | − new = build_reserve_entry(re.address, re.size); | |
| 720 | + new = build_reserve_entry(address, size); | |
| 728 | 721 | reservelist = add_reserve_entry(reservelist, new); |
| 729 | 722 | } |
| 730 | 723 | |
| @@ -817,6 +810,7 @@ static struct node *unflatten_tree(struct inbuf *dtbuf, · 86 unmodified lines | ||
| 817 | 810 | struct dt_info *dt_from_blob(const char *fname) |
| 818 | 811 | { |
| 819 | 812 | FILE *f; |
| 813 | + fdt32_t magic_buf, totalsize_buf; | |
| 820 | 814 | uint32_t magic, totalsize, version, size_dt, boot_cpuid_phys; |
| 821 | 815 | uint32_t off_dt, off_str, off_mem_rsvmap; |
| 822 | 816 | int rc; |
| @@ -833,7 +827,7 @@ struct dt_info *dt_from_blob(const char *fname) · 10 unmodified lines | ||
| 833 | 827 | |
| 834 | 828 | f = srcfile_relative_open(fname, NULL); |
| 835 | 829 | |
| 836 | − rc = fread(&magic, sizeof(magic), 1, f); | |
| 830 | + rc = fread(&magic_buf, sizeof(magic_buf), 1, f); | |
| 837 | 831 | if (ferror(f)) |
| 838 | 832 | die("Error reading DT blob magic number: %s\n", |
| 839 | 833 | strerror(errno)); |
| @@ -844,11 +838,11 @@ struct dt_info *dt_from_blob(const char *fname) · 4 unmodified lines | ||
| 844 | 838 | die("Mysterious short read reading magic number\n"); |
| 845 | 839 | } |
| 846 | 840 | |
| 847 | − magic = fdt32_to_cpu(magic); | |
| 841 | + magic = fdt32_to_cpu(magic_buf); | |
| 848 | 842 | if (magic != FDT_MAGIC) |
| 849 | 843 | die("Blob has incorrect magic number\n"); |
| 850 | 844 | |
| 851 | − rc = fread(&totalsize, sizeof(totalsize), 1, f); | |
| 845 | + rc = fread(&totalsize_buf, sizeof(totalsize_buf), 1, f); | |
| 852 | 846 | if (ferror(f)) |
| 853 | 847 | die("Error reading DT blob size: %s\n", strerror(errno)); |
| 854 | 848 | if (rc < 1) { |
| @@ -858,7 +852,7 @@ struct dt_info *dt_from_blob(const char *fname) · 3 unmodified lines | ||
| 858 | 852 | die("Mysterious short read reading blob size\n"); |
| 859 | 853 | } |
| 860 | 854 | |
| 861 | − totalsize = fdt32_to_cpu(totalsize); | |
| 855 | + totalsize = fdt32_to_cpu(totalsize_buf); | |
| 862 | 856 | if (totalsize < FDT_V1_SIZE) |
| 863 | 857 | die("DT blob size (%d) is too small\n", totalsize); |
| 864 | 858 | |
| @@ -283,7 +283,8 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name, · 282 unmodified lines | ||
| 283 | 283 | if (err) |
| 284 | 284 | return err; |
| 285 | 285 | |
| 286 | − memcpy(prop->data, val, len); | |
| 286 | + if (len) | |
| 287 | + memcpy(prop->data, val, len); | |
| 287 | 288 | return 0; |
| 288 | 289 | } |
| 289 | 290 | |
| @@ -143,7 +143,9 @@ · 142 unmodified lines | ||
| 143 | 143 | /* Low-level functions (you probably don't need these) */ |
| 144 | 144 | /**********************************************************************/ |
| 145 | 145 | |
| 146 | +#ifndef SWIG /* This function is not useful in Python */ | |
| 146 | 147 | const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int checklen); |
| 148 | +#endif | |
| 147 | 149 | static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen) |
| 148 | 150 | { |
| 149 | 151 | return (void *)(uintptr_t)fdt_offset_ptr(fdt, offset, checklen); |
| @@ -210,7 +212,6 @@ int fdt_next_subnode(const void *fdt, int offset); · 60 unmodified lines | ||
| 210 | 212 | /**********************************************************************/ |
| 211 | 213 | /* General functions */ |
| 212 | 214 | /**********************************************************************/ |
| 213 | − | |
| 214 | 215 | #define fdt_get_header(fdt, field) \ |
| 215 | 216 | (fdt32_to_cpu(((const struct fdt_header *)(fdt))->field)) |
| 216 | 217 | #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); · 137 unmodified lines | ||
| 354 | 355 | * useful for finding subnodes based on a portion of a larger string, |
| 355 | 356 | * such as a full path. |
| 356 | 357 | */ |
| 358 | +#ifndef SWIG /* Not available in Python */ | |
| 357 | 359 | int fdt_subnode_offset_namelen(const void *fdt, int parentoffset, |
| 358 | 360 | const char *name, int namelen); |
| 361 | +#endif | |
| 359 | 362 | /** |
| 360 | 363 | * fdt_subnode_offset - find a subnode of a given node |
| 361 | 364 | * @fdt: pointer to the device tree blob |
| @@ -391,7 +394,9 @@ int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name); · 29 unmodified lines | ||
| 391 | 394 | * Identical to fdt_path_offset(), but only consider the first namelen |
| 392 | 395 | * characters of path as the path name. |
| 393 | 396 | */ |
| 397 | +#ifndef SWIG /* Not available in Python */ | |
| 394 | 398 | int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen); |
| 399 | +#endif | |
| 395 | 400 | |
| 396 | 401 | /** |
| 397 | 402 | * 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, · 152 unmodified lines | ||
| 550 | 555 | * Identical to fdt_get_property(), but only examine the first namelen |
| 551 | 556 | * characters of name for matching the property name. |
| 552 | 557 | */ |
| 558 | +#ifndef SWIG /* Not available in Python */ | |
| 553 | 559 | const struct fdt_property *fdt_get_property_namelen(const void *fdt, |
| 554 | 560 | int nodeoffset, |
| 555 | 561 | const char *name, |
| 556 | 562 | int namelen, int *lenp); |
| 563 | +#endif | |
| 557 | 564 | |
| 558 | 565 | /** |
| 559 | 566 | * 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, · 64 unmodified lines | ||
| 624 | 631 | * -FDT_ERR_BADSTRUCTURE, |
| 625 | 632 | * -FDT_ERR_TRUNCATED, standard meanings |
| 626 | 633 | */ |
| 634 | +#ifndef SWIG /* This function is not useful in Python */ | |
| 627 | 635 | const void *fdt_getprop_by_offset(const void *fdt, int offset, |
| 628 | 636 | const char **namep, int *lenp); |
| 637 | +#endif | |
| 629 | 638 | |
| 630 | 639 | /** |
| 631 | 640 | * fdt_getprop_namelen - get property value based on substring |
| @@ -638,6 +647,7 @@ const void *fdt_getprop_by_offset(const void *fdt, int offset, · 6 unmodified lines | ||
| 638 | 647 | * Identical to fdt_getprop(), but only examine the first namelen |
| 639 | 648 | * characters of name for matching the property name. |
| 640 | 649 | */ |
| 650 | +#ifndef SWIG /* Not available in Python */ | |
| 641 | 651 | const void *fdt_getprop_namelen(const void *fdt, int nodeoffset, |
| 642 | 652 | const char *name, int namelen, int *lenp); |
| 643 | 653 | 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, · 3 unmodified lines | ||
| 647 | 657 | return (void *)(uintptr_t)fdt_getprop_namelen(fdt, nodeoffset, name, |
| 648 | 658 | namelen, lenp); |
| 649 | 659 | } |
| 660 | +#endif | |
| 650 | 661 | |
| 651 | 662 | /** |
| 652 | 663 | * fdt_getprop - retrieve the value of a given property |
| @@ -707,8 +718,10 @@ uint32_t fdt_get_phandle(const void *fdt, int nodeoffset); · 54 unmodified lines | ||
| 707 | 718 | * Identical to fdt_get_alias(), but only examine the first namelen |
| 708 | 719 | * characters of name for matching the alias name. |
| 709 | 720 | */ |
| 721 | +#ifndef SWIG /* Not available in Python */ | |
| 710 | 722 | const char *fdt_get_alias_namelen(const void *fdt, |
| 711 | 723 | const char *name, int namelen); |
| 724 | +#endif | |
| 712 | 725 | |
| 713 | 726 | /** |
| 714 | 727 | * fdt_get_alias - retrieve the path referenced by a given alias |
| @@ -1106,10 +1119,12 @@ int fdt_size_cells(const void *fdt, int nodeoffset); · 391 unmodified lines | ||
| 1106 | 1119 | * of the name. It is useful when you want to manipulate only one value of |
| 1107 | 1120 | * an array and you have a string that doesn't end with \0. |
| 1108 | 1121 | */ |
| 1122 | +#ifndef SWIG /* Not available in Python */ | |
| 1109 | 1123 | int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset, |
| 1110 | 1124 | const char *name, int namelen, |
| 1111 | 1125 | uint32_t idx, const void *val, |
| 1112 | 1126 | int len); |
| 1127 | +#endif | |
| 1113 | 1128 | |
| 1114 | 1129 | /** |
| 1115 | 1130 | * 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, · 23 unmodified lines | ||
| 1139 | 1154 | * -FDT_ERR_BADSTRUCTURE, |
| 1140 | 1155 | * -FDT_ERR_TRUNCATED, standard meanings |
| 1141 | 1156 | */ |
| 1157 | +#ifndef SWIG /* Not available in Python */ | |
| 1142 | 1158 | int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name, |
| 1143 | 1159 | const void *val, int len); |
| 1160 | +#endif | |
| 1144 | 1161 | |
| 1145 | 1162 | /** |
| 1146 | 1163 | * fdt_setprop_inplace_u32 - change the value of a 32-bit integer property |
| @@ -1527,6 +1544,36 @@ static inline int fdt_setprop_cell(void *fdt, int nodeoffset, const char *name, · 380 unmodified lines | ||
| 1527 | 1544 | #define fdt_setprop_string(fdt, nodeoffset, name, str) \ |
| 1528 | 1545 | fdt_setprop((fdt), (nodeoffset), (name), (str), strlen(str)+1) |
| 1529 | 1546 | |
| 1547 | + | |
| 1548 | +/** | |
| 1549 | + * fdt_setprop_empty - set a property to an empty value | |
| 1550 | + * @fdt: pointer to the device tree blob | |
| 1551 | + * @nodeoffset: offset of the node whose property to change | |
| 1552 | + * @name: name of the property to change | |
| 1553 | + * | |
| 1554 | + * fdt_setprop_empty() sets the value of the named property in the | |
| 1555 | + * given node to an empty (zero length) value, or creates a new empty | |
| 1556 | + * property if it does not already exist. | |
| 1557 | + * | |
| 1558 | + * This function may insert or delete data from the blob, and will | |
| 1559 | + * therefore change the offsets of some existing nodes. | |
| 1560 | + * | |
| 1561 | + * returns: | |
| 1562 | + * 0, on success | |
| 1563 | + * -FDT_ERR_NOSPACE, there is insufficient free space in the blob to | |
| 1564 | + * contain the new property value | |
| 1565 | + * -FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag | |
| 1566 | + * -FDT_ERR_BADLAYOUT, | |
| 1567 | + * -FDT_ERR_BADMAGIC, | |
| 1568 | + * -FDT_ERR_BADVERSION, | |
| 1569 | + * -FDT_ERR_BADSTATE, | |
| 1570 | + * -FDT_ERR_BADSTRUCTURE, | |
| 1571 | + * -FDT_ERR_BADLAYOUT, | |
| 1572 | + * -FDT_ERR_TRUNCATED, standard meanings | |
| 1573 | + */ | |
| 1574 | +#define fdt_setprop_empty(fdt, nodeoffset, name) \ | |
| 1575 | + fdt_setprop((fdt), (nodeoffset), (name), NULL, 0) | |
| 1576 | + | |
| 1530 | 1577 | /** |
| 1531 | 1578 | * fdt_appendprop - append to or create a property |
| 1532 | 1579 | * @fdt: pointer to the device tree blob |
| @@ -1704,8 +1751,10 @@ int fdt_delprop(void *fdt, int nodeoffset, const char *name); · 171 unmodified lines | ||
| 1704 | 1751 | * creating subnodes based on a portion of a larger string, such as a |
| 1705 | 1752 | * full path. |
| 1706 | 1753 | */ |
| 1754 | +#ifndef SWIG /* Not available in Python */ | |
| 1707 | 1755 | int fdt_add_subnode_namelen(void *fdt, int parentoffset, |
| 1708 | 1756 | const char *name, int namelen); |
| 1757 | +#endif | |
| 1709 | 1758 | |
| 1710 | 1759 | /** |
| 1711 | 1760 | * fdt_add_subnode - creates a new node |
| @@ -58,16 +58,16 @@ · 57 unmodified lines | ||
| 58 | 58 | #include <string.h> |
| 59 | 59 | |
| 60 | 60 | #ifdef __CHECKER__ |
| 61 | −#define __force __attribute__((force)) | |
| 62 | −#define __bitwise __attribute__((bitwise)) | |
| 61 | +#define FDT_FORCE __attribute__((force)) | |
| 62 | +#define FDT_BITWISE __attribute__((bitwise)) | |
| 63 | 63 | #else |
| 64 | −#define __force | |
| 65 | −#define __bitwise | |
| 64 | +#define FDT_FORCE | |
| 65 | +#define FDT_BITWISE | |
| 66 | 66 | #endif |
| 67 | 67 | |
| 68 | −typedef uint16_t __bitwise fdt16_t; | |
| 69 | −typedef uint32_t __bitwise fdt32_t; | |
| 70 | −typedef uint64_t __bitwise fdt64_t; | |
| 68 | +typedef uint16_t FDT_BITWISE fdt16_t; | |
| 69 | +typedef uint32_t FDT_BITWISE fdt32_t; | |
| 70 | +typedef uint64_t FDT_BITWISE fdt64_t; | |
| 71 | 71 | |
| 72 | 72 | #define EXTRACT_BYTE(x, n) ((unsigned long long)((uint8_t *)&x)[n]) |
| 73 | 73 | #define CPU_TO_FDT16(x) ((EXTRACT_BYTE(x, 0) << 8) | EXTRACT_BYTE(x, 1)) |
| @@ -80,29 +80,29 @@ typedef uint64_t __bitwise fdt64_t; · 6 unmodified lines | ||
| 80 | 80 | |
| 81 | 81 | static inline uint16_t fdt16_to_cpu(fdt16_t x) |
| 82 | 82 | { |
| 83 | − return (__force uint16_t)CPU_TO_FDT16(x); | |
| 83 | + return (FDT_FORCE uint16_t)CPU_TO_FDT16(x); | |
| 84 | 84 | } |
| 85 | 85 | static inline fdt16_t cpu_to_fdt16(uint16_t x) |
| 86 | 86 | { |
| 87 | − return (__force fdt16_t)CPU_TO_FDT16(x); | |
| 87 | + return (FDT_FORCE fdt16_t)CPU_TO_FDT16(x); | |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | static inline uint32_t fdt32_to_cpu(fdt32_t x) |
| 91 | 91 | { |
| 92 | − return (__force uint32_t)CPU_TO_FDT32(x); | |
| 92 | + return (FDT_FORCE uint32_t)CPU_TO_FDT32(x); | |
| 93 | 93 | } |
| 94 | 94 | static inline fdt32_t cpu_to_fdt32(uint32_t x) |
| 95 | 95 | { |
| 96 | − return (__force fdt32_t)CPU_TO_FDT32(x); | |
| 96 | + return (FDT_FORCE fdt32_t)CPU_TO_FDT32(x); | |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | static inline uint64_t fdt64_to_cpu(fdt64_t x) |
| 100 | 100 | { |
| 101 | − return (__force uint64_t)CPU_TO_FDT64(x); | |
| 101 | + return (FDT_FORCE uint64_t)CPU_TO_FDT64(x); | |
| 102 | 102 | } |
| 103 | 103 | static inline fdt64_t cpu_to_fdt64(uint64_t x) |
| 104 | 104 | { |
| 105 | − return (__force fdt64_t)CPU_TO_FDT64(x); | |
| 105 | + return (FDT_FORCE fdt64_t)CPU_TO_FDT64(x); | |
| 106 | 106 | } |
| 107 | 107 | #undef CPU_TO_FDT64 |
| 108 | 108 | #undef CPU_TO_FDT32 |
| @@ -242,7 +242,7 @@ void delete_property_by_name(struct node *node, char *name) · 241 unmodified lines | ||
| 242 | 242 | struct property *prop = node->proplist; |
| 243 | 243 | |
| 244 | 244 | while (prop) { |
| 245 | − if (!strcmp(prop->name, name)) { | |
| 245 | + if (streq(prop->name, name)) { | |
| 246 | 246 | delete_property(prop); |
| 247 | 247 | return; |
| 248 | 248 | } |
| @@ -275,7 +275,7 @@ void delete_node_by_name(struct node *parent, char *name) · 26 unmodified lines | ||
| 275 | 275 | struct node *node = parent->children; |
| 276 | 276 | |
| 277 | 277 | while (node) { |
| 278 | − if (!strcmp(node->name, name)) { | |
| 278 | + if (streq(node->name, name)) { | |
| 279 | 279 | delete_node(node); |
| 280 | 280 | return; |
| 281 | 281 | } |
| @@ -319,8 +319,8 @@ struct reserve_info *build_reserve_entry(uint64_t address, uint64_t size) · 37 unmodified lines | ||
| 319 | 319 | |
| 320 | 320 | memset(new, 0, sizeof(*new)); |
| 321 | 321 | |
| 322 | − new->re.address = address; | |
| 323 | − new->re.size = size; | |
| 322 | + new->address = address; | |
| 323 | + new->size = size; | |
| 324 | 324 | |
| 325 | 325 | return new; |
| 326 | 326 | } |
| @@ -393,7 +393,7 @@ struct property *get_property(struct node *node, const char *propname) · 66 unmodified lines | ||
| 393 | 393 | cell_t propval_cell(struct property *prop) |
| 394 | 394 | { |
| 395 | 395 | assert(prop->val.len == sizeof(cell_t)); |
| 396 | − return fdt32_to_cpu(*((cell_t *)prop->val.val)); | |
| 396 | + return fdt32_to_cpu(*((fdt32_t *)prop->val.val)); | |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | struct property *get_property_by_label(struct node *tree, const char *label, |
| @@ -599,13 +599,13 @@ static int cmp_reserve_info(const void *ax, const void *bx) · 199 unmodified lines | ||
| 599 | 599 | a = *((const struct reserve_info * const *)ax); |
| 600 | 600 | b = *((const struct reserve_info * const *)bx); |
| 601 | 601 | |
| 602 | − if (a->re.address < b->re.address) | |
| 602 | + if (a->address < b->address) | |
| 603 | 603 | return -1; |
| 604 | − else if (a->re.address > b->re.address) | |
| 604 | + else if (a->address > b->address) | |
| 605 | 605 | return 1; |
| 606 | − else if (a->re.size < b->re.size) | |
| 606 | + else if (a->size < b->size) | |
| 607 | 607 | return -1; |
| 608 | − else if (a->re.size > b->re.size) | |
| 608 | + else if (a->size > b->size) | |
| 609 | 609 | return 1; |
| 610 | 610 | else |
| 611 | 611 | return 0; |
| @@ -847,6 +847,8 @@ static void add_fixup_entry(struct dt_info *dti, struct node *fn, · 235 unmodified lines | ||
| 847 | 847 | xasprintf(&entry, "%s:%s:%u", |
| 848 | 848 | node->fullpath, prop->name, m->offset); |
| 849 | 849 | append_to_property(fn, m->ref, entry, strlen(entry) + 1); |
| 850 | + | |
| 851 | + free(entry); | |
| 850 | 852 | } |
| 851 | 853 | |
| 852 | 854 | static void generate_fixups_tree_internal(struct dt_info *dti, |
| @@ -900,7 +902,7 @@ static void add_local_fixup_entry(struct dt_info *dti, · 47 unmodified lines | ||
| 900 | 902 | struct node *refnode) |
| 901 | 903 | { |
| 902 | 904 | struct node *wn, *nwn; /* local fixup node, walk node, new */ |
| 903 | − uint32_t value_32; | |
| 905 | + fdt32_t value_32; | |
| 904 | 906 | char **compp; |
| 905 | 907 | int i, depth; |
| 906 | 908 | |
| @@ -252,7 +252,7 @@ srcpos_string(struct srcpos *pos) · 251 unmodified lines | ||
| 252 | 252 | const char *fname = "<no-file>"; |
| 253 | 253 | char *pos_str; |
| 254 | 254 | |
| 255 | − if (pos) | |
| 255 | + if (pos->file && pos->file->name) | |
| 256 | 256 | fname = pos->file->name; |
| 257 | 257 | |
| 258 | 258 | |
| @@ -22,6 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | |
| 23 | 23 | #include <stdio.h> |
| 24 | 24 | #include <stdbool.h> |
| 25 | +#include "util.h" | |
| 25 | 26 | |
| 26 | 27 | struct srcfile_state { |
| 27 | 28 | FILE *f; |
| @@ -106,12 +107,10 @@ extern void srcpos_update(struct srcpos *pos, const char *text, int len); · 78 unmodified lines | ||
| 106 | 107 | extern struct srcpos *srcpos_copy(struct srcpos *pos); |
| 107 | 108 | extern char *srcpos_string(struct srcpos *pos); |
| 108 | 109 | |
| 109 | −extern void srcpos_verror(struct srcpos *pos, const char *prefix, | |
| 110 | − const char *fmt, va_list va) | |
| 111 | − __attribute__((format(printf, 3, 0))); | |
| 112 | −extern void srcpos_error(struct srcpos *pos, const char *prefix, | |
| 113 | − const char *fmt, ...) | |
| 114 | − __attribute__((format(printf, 3, 4))); | |
| 110 | +extern void PRINTF(3, 0) srcpos_verror(struct srcpos *pos, const char *prefix, | |
| 111 | + const char *fmt, va_list va); | |
| 112 | +extern void PRINTF(3, 4) srcpos_error(struct srcpos *pos, const char *prefix, | |
| 113 | + const char *fmt, ...); | |
| 115 | 114 | |
| 116 | 115 | extern void srcpos_set_line(char *f, int l); |
| 117 | 116 | |
| @@ -137,7 +137,7 @@ static void write_propval_string(FILE *f, struct data val) · 136 unmodified lines | ||
| 137 | 137 | static void write_propval_cells(FILE *f, struct data val) |
| 138 | 138 | { |
| 139 | 139 | void *propend = val.val + val.len; |
| 140 | − cell_t *cp = (cell_t *)val.val; | |
| 140 | + fdt32_t *cp = (fdt32_t *)val.val; | |
| 141 | 141 | struct marker *m = val.markers; |
| 142 | 142 | |
| 143 | 143 | fprintf(f, "<"); |
| @@ -275,8 +275,8 @@ void dt_to_source(FILE *f, struct dt_info *dti) · 131 unmodified lines | ||
| 275 | 275 | for_each_label(re->labels, l) |
| 276 | 276 | fprintf(f, "%s: ", l->label); |
| 277 | 277 | fprintf(f, "/memreserve/\t0x%016llx 0x%016llx;\n", |
| 278 | − (unsigned long long)re->re.address, | |
| 279 | − (unsigned long long)re->re.size); | |
| 278 | + (unsigned long long)re->address, | |
| 279 | + (unsigned long long)re->size); | |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | write_tree_source_node(f, dti->dt, 0); |
| @@ -36,10 +36,19 @@ DTC_SOURCE="checks.c data.c dtc.c dtc.h flattree.c fstree.c livetree.c srcpos.c · 35 unmodified lines | ||
| 36 | 36 | DTC_GENERATED="dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h" |
| 37 | 37 | LIBFDT_SOURCE="Makefile.libfdt fdt.c fdt.h fdt_empty_tree.c fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c fdt_wip.c libfdt.h libfdt_env.h libfdt_internal.h" |
| 38 | 38 | |
| 39 | +get_last_dtc_version() { | |
| 40 | + git log --oneline scripts/dtc/ | grep 'upstream' | head -1 | sed -e 's/^.* \(.*\)/\1/' | |
| 41 | +} | |
| 42 | + | |
| 43 | +last_dtc_ver=$(get_last_dtc_version) | |
| 44 | + | |
| 39 | 45 | # Build DTC |
| 40 | 46 | cd $DTC_UPSTREAM_PATH |
| 41 | 47 | make clean |
| 42 | 48 | make check |
| 49 | +dtc_version=$(git describe HEAD) | |
| 50 | +dtc_log=$(git log --oneline ${last_dtc_ver}..) | |
| 51 | + | |
| 43 | 52 | |
| 44 | 53 | # Copy the files into the Linux tree |
| 45 | 54 | cd $DTC_LINUX_PATH |
| @@ -60,4 +69,13 @@ sed -i -- 's/#include <libfdt_env.h>/#include "libfdt_env.h"/g' ./libfdt/libfdt. · 14 unmodified lines | ||
| 60 | 69 | sed -i -- 's/#include <fdt.h>/#include "fdt.h"/g' ./libfdt/libfdt.h |
| 61 | 70 | git add ./libfdt/libfdt.h |
| 62 | 71 | |
| 63 | −git commit -e -v -m "scripts/dtc: Update to upstream version [CHANGEME]" | |
| 72 | +commit_msg=$(cat << EOF | |
| 73 | +scripts/dtc: Update to upstream version ${dtc_version} | |
| 74 | + | |
| 75 | +This adds the following commits from upstream: | |
| 76 | + | |
| 77 | +${dtc_log} | |
| 78 | +EOF | |
| 79 | +) | |
| 80 | + | |
| 81 | +git commit -e -v -s -m "${commit_msg}" | |
| @@ -396,7 +396,7 @@ void utilfdt_print_data(const char *data, int len) · 395 unmodified lines | ||
| 396 | 396 | } while (s < data + len); |
| 397 | 397 | |
| 398 | 398 | } else if ((len % 4) == 0) { |
| 399 | − const uint32_t *cell = (const uint32_t *)data; | |
| 399 | + const fdt32_t *cell = (const fdt32_t *)data; | |
| 400 | 400 | |
| 401 | 401 | printf(" = <"); |
| 402 | 402 | for (i = 0, len /= 4; i < len; i++) |
| @@ -412,15 +412,16 @@ void utilfdt_print_data(const char *data, int len) · 9 unmodified lines | ||
| 412 | 412 | } |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | −void util_version(void) | |
| 415 | +void NORETURN util_version(void) | |
| 416 | 416 | { |
| 417 | 417 | printf("Version: %s\n", DTC_VERSION); |
| 418 | 418 | exit(0); |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | −void util_usage(const char *errmsg, const char *synopsis, | |
| 422 | − const char *short_opts, struct option const long_opts[], | |
| 423 | − const char * const opts_help[]) | |
| 421 | +void NORETURN util_usage(const char *errmsg, const char *synopsis, | |
| 422 | + const char *short_opts, | |
| 423 | + struct option const long_opts[], | |
| 424 | + const char * const opts_help[]) | |
| 424 | 425 | { |
| 425 | 426 | FILE *fp = errmsg ? stderr : stdout; |
| 426 | 427 | const char a_arg[] = "<arg>"; |
| @@ -25,9 +25,17 @@ · 24 unmodified lines | ||
| 25 | 25 | * USA |
| 26 | 26 | */ |
| 27 | 27 | |
| 28 | +#ifdef __GNUC__ | |
| 29 | +#define PRINTF(i, j) __attribute__((format (printf, i, j))) | |
| 30 | +#define NORETURN __attribute__((noreturn)) | |
| 31 | +#else | |
| 32 | +#define PRINTF(i, j) | |
| 33 | +#define NORETURN | |
| 34 | +#endif | |
| 35 | + | |
| 28 | 36 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) |
| 29 | 37 | |
| 30 | −static inline void __attribute__((noreturn)) die(const char *str, ...) | |
| 38 | +static inline void NORETURN PRINTF(1, 2) die(const char *str, ...) | |
| 31 | 39 | { |
| 32 | 40 | va_list ap; |
| 33 | 41 | |
| @@ -53,13 +61,14 @@ static inline void *xrealloc(void *p, size_t len) · 19 unmodified lines | ||
| 53 | 61 | void *new = realloc(p, len); |
| 54 | 62 | |
| 55 | 63 | if (!new) |
| 56 | − die("realloc() failed (len=%d)\n", len); | |
| 64 | + die("realloc() failed (len=%zd)\n", len); | |
| 57 | 65 | |
| 58 | 66 | return new; |
| 59 | 67 | } |
| 60 | 68 | |
| 61 | 69 | extern char *xstrdup(const char *s); |
| 62 | −extern int xasprintf(char **strp, const char *fmt, ...); | |
| 70 | + | |
| 71 | +extern int PRINTF(2, 3) xasprintf(char **strp, const char *fmt, ...); | |
| 63 | 72 | extern char *join_path(const char *path, const char *name); |
| 64 | 73 | |
| 65 | 74 | /** |
| @@ -188,7 +197,7 @@ void utilfdt_print_data(const char *data, int len); · 122 unmodified lines | ||
| 188 | 197 | /** |
| 189 | 198 | * Show source version and exit |
| 190 | 199 | */ |
| 191 | −void util_version(void) __attribute__((noreturn)); | |
| 200 | +void NORETURN util_version(void); | |
| 192 | 201 | |
| 193 | 202 | /** |
| 194 | 203 | * Show usage and exit |
| @@ -202,9 +211,10 @@ void util_version(void) __attribute__((noreturn)); · 7 unmodified lines | ||
| 202 | 211 | * @param long_opts The structure of long options |
| 203 | 212 | * @param opts_help An array of help strings (should align with long_opts) |
| 204 | 213 | */ |
| 205 | −void util_usage(const char *errmsg, const char *synopsis, | |
| 206 | − const char *short_opts, struct option const long_opts[], | |
| 207 | − const char * const opts_help[]) __attribute__((noreturn)); | |
| 214 | +void NORETURN util_usage(const char *errmsg, const char *synopsis, | |
| 215 | + const char *short_opts, | |
| 216 | + struct option const long_opts[], | |
| 217 | + const char * const opts_help[]); | |
| 208 | 218 | |
| 209 | 219 | /** |
| 210 | 220 | * Show usage and exit |
| @@ -1 +1 @@ | ||
| 1 | −#define DTC_VERSION "DTC 1.4.2-g0931cea3" | |
| 1 | +#define DTC_VERSION "DTC 1.4.4-g756ffc4f" | |