* overlay_apply_node - Merges a node into the base device tree * @fdt: Base Device Tree blob * @target: Node offset in the base device tree to apply the fragment to * @fdto: Device tree overlay blob * @node: Node offset in the overlay holding the changes to merge * * overlay_apply_node() merges a node into a target base device tree * node pointed. * * This is part of the final step in the
| 540 | * Negative error code on failure |
| 541 | */ |
| 542 | static int overlay_apply_node(void *fdt, int target, |
| 543 | void *fdto, int node) |
| 544 | { |
| 545 | int property; |
| 546 | int subnode; |
| 547 | |
| 548 | fdt_for_each_property_offset(property, fdto, node) { |
| 549 | const char *name; |
| 550 | const void *prop; |
| 551 | int prop_len; |
| 552 | int ret; |
| 553 | |
| 554 | prop = fdt_getprop_by_offset(fdto, property, &name, |
| 555 | &prop_len); |
| 556 | if (prop_len == -FDT_ERR_NOTFOUND) |
| 557 | return -FDT_ERR_INTERNAL; |
| 558 | if (prop_len < 0) |
| 559 | return prop_len; |
| 560 | |
| 561 | ret = fdt_setprop(fdt, target, name, prop, prop_len); |
| 562 | if (ret) |
| 563 | return ret; |
| 564 | } |
| 565 | |
| 566 | fdt_for_each_subnode(subnode, fdto, node) { |
| 567 | const char *name = fdt_get_name(fdto, subnode, NULL); |
| 568 | int nnode; |
| 569 | int ret; |
| 570 | |
| 571 | nnode = fdt_add_subnode(fdt, target, name); |
| 572 | if (nnode == -FDT_ERR_EXISTS) { |
| 573 | nnode = fdt_subnode_offset(fdt, target, name); |
| 574 | if (nnode == -FDT_ERR_NOTFOUND) |
| 575 | return -FDT_ERR_INTERNAL; |
| 576 | } |
| 577 | |
| 578 | if (nnode < 0) |
| 579 | return nnode; |
| 580 | |
| 581 | ret = overlay_apply_node(fdt, nnode, fdto, subnode); |
| 582 | if (ret) |
| 583 | return ret; |
| 584 | } |
| 585 | |
| 586 | return 0; |
| 587 | } |
| 588 | |
| 589 | /** |
| 590 | * overlay_merge - Merge an overlay into its base device tree |
no test coverage detected