/* returns: 0 on success Negative error code on failure  */
static int overlay_merge(void *fdt, void *fdto)
/* returns: 0 on success Negative error code on failure  */
static int overlay_merge(void *fdt, void *fdto)
{
  int  fragment;
  fdt_for_each_subnode (fragment, fdto, 0) {
    int  overlay;
    int  target;
    int  ret;
    overlay = fdt_subnode_offset (fdto, fragment, "__overlay__");
    if (overlay == -FDT_ERR_NOTFOUND) {
      continue;
    }
    if (overlay < 0) {
      return overlay;
    }
    target = overlay_get_target (fdt, fdto, fragment, NULL);
    if (target < 0) {
      return target;
    }
    ret = overlay_apply_node (fdt, target, fdto, overlay);
    if (ret) {
      return ret;
    }
  }
  return 0;
}