/* returns: the targetted node offset in the base device tree Negative error code on error  */
static int overlay_get_target(const void *fdt, const void *fdto, int fragment)
/* returns: the targetted node offset in the base device tree Negative error code on error  */
static int overlay_get_target(const void *fdt, const void *fdto, int fragment)
{
	uint32_t phandle;
	const char *path;
	int path_len;
	phandle = overlay_get_target_phandle(fdto, fragment);
	if (phandle == (uint32_t)-1)
		return -FDT_ERR_BADPHANDLE;
	if (phandle)
		return fdt_node_offset_by_phandle(fdt, phandle);
	path = fdt_getprop(fdto, fragment, "target-path", &path_len);
	if (!path) {
		if (path_len == -FDT_ERR_NOTFOUND)
			return -FDT_ERR_BADOVERLAY;
		return path_len;
	}
	return fdt_path_offset(fdt, path);
}