void fdt_build_clock_node(void *host_fdt, void *guest_fdt,

                         uint32_t host_phandle,

                         uint32_t guest_phandle)

{

    char *node_path = NULL;

    char *nodename;

    const void *r;

    int ret, node_offset, prop_len, path_len = 16;



    node_offset = fdt_node_offset_by_phandle(host_fdt, host_phandle);

    if (node_offset <= 0) {

        error_setg(&error_fatal,

                   "not able to locate clock handle %d in host device tree",

                   host_phandle);

    }

    node_path = g_malloc(path_len);

    while ((ret = fdt_get_path(host_fdt, node_offset, node_path, path_len))

            == -FDT_ERR_NOSPACE) {

        path_len += 16;

        node_path = g_realloc(node_path, path_len);

    }

    if (ret < 0) {

        error_setg(&error_fatal,

                   "not able to retrieve node path for clock handle %d",

                   host_phandle);

    }



    r = qemu_fdt_getprop(host_fdt, node_path, "compatible", &prop_len,

                         &error_fatal);

    if (strcmp(r, "fixed-clock")) {

        error_setg(&error_fatal,

                   "clock handle %d is not a fixed clock", host_phandle);

    }



    nodename = strrchr(node_path, '/');

    qemu_fdt_add_subnode(guest_fdt, nodename);



    copy_properties_from_host(clock_copied_properties,

                              ARRAY_SIZE(clock_copied_properties),

                              host_fdt, guest_fdt,

                              node_path, nodename);



    qemu_fdt_setprop_cell(guest_fdt, nodename, "phandle", guest_phandle);



    g_free(node_path);

}

void fdt_build_clock_node(void *host_fdt, void *guest_fdt,

                         uint32_t host_phandle,

                         uint32_t guest_phandle)

{

    char *node_path = NULL;

    char *nodename;

    const void *r;

    int ret, node_offset, prop_len, path_len = 16;



    node_offset = fdt_node_offset_by_phandle(host_fdt, host_phandle);

    if (node_offset <= 0) {

        error_setg(&error_fatal,

                   "not able to locate clock handle %d in host device tree",

                   host_phandle);

    }

    node_path = g_malloc(path_len);

    while ((ret = fdt_get_path(host_fdt, node_offset, node_path, path_len))

            == -FDT_ERR_NOSPACE) {

        path_len += 16;

        node_path = g_realloc(node_path, path_len);

    }

    if (ret < 0) {

        error_setg(&error_fatal,

                   "not able to retrieve node path for clock handle %d",

                   host_phandle);

    }



    r = qemu_fdt_getprop(host_fdt, node_path, "compatible", &prop_len,

                         &error_fatal);

    if (strcmp(r, "fixed-clock")) {

        error_setg(&error_fatal,

                   "clock handle %d is not a fixed clock", host_phandle);

    }



    nodename = strrchr(node_path, '/');

    qemu_fdt_add_subnode(guest_fdt, nodename);



    copy_properties_from_host(clock_copied_properties,

                              ARRAY_SIZE(clock_copied_properties),

                              host_fdt, guest_fdt,

                              node_path, nodename);



    qemu_fdt_setprop_cell(guest_fdt, nodename, "phandle", guest_phandle);



    g_free(node_path);

}

void FUNC_0(void *VAR_0, void *VAR_1,

                         uint32_t VAR_2,

                         uint32_t VAR_3)

{

    char *VAR_4 = NULL;

    char *VAR_5;

    const void *VAR_6;

    int VAR_7, VAR_8, VAR_9, VAR_10 = 16;



    VAR_8 = fdt_node_offset_by_phandle(VAR_0, VAR_2);

    if (VAR_8 <= 0) {

        error_setg(&error_fatal,

                   "not able to locate clock handle %d in host device tree",

                   VAR_2);

    }

    VAR_4 = g_malloc(VAR_10);

    while ((VAR_7 = fdt_get_path(VAR_0, VAR_8, VAR_4, VAR_10))

            == -FDT_ERR_NOSPACE) {

        VAR_10 += 16;

        VAR_4 = g_realloc(VAR_4, VAR_10);

    }

    if (VAR_7 < 0) {

        error_setg(&error_fatal,

                   "not able to retrieve node path for clock handle %d",

                   VAR_2);

    }



    VAR_6 = qemu_fdt_getprop(VAR_0, VAR_4, "compatible", &VAR_9,

                         &error_fatal);

    if (strcmp(VAR_6, "fixed-clock")) {

        error_setg(&error_fatal,

                   "clock handle %d is not a fixed clock", VAR_2);

    }



    VAR_5 = strrchr(VAR_4, '/');

    qemu_fdt_add_subnode(VAR_1, VAR_5);



    copy_properties_from_host(clock_copied_properties,

                              ARRAY_SIZE(clock_copied_properties),

                              VAR_0, VAR_1,

                              VAR_4, VAR_5);



    qemu_fdt_setprop_cell(VAR_1, VAR_5, "phandle", VAR_3);



    g_free(VAR_4);

}

void FUNC_0(void *VAR_0, void *VAR_1,
uint32_t VAR_2,
uint32_t VAR_3)
{ char *VAR_4 = NULL; char *VAR_5; const void *VAR_6; int VAR_7, VAR_8, VAR_9, VAR_10 = 16; VAR_8 = fdt_node_offset_by_phandle(VAR_0, VAR_2); if (VAR_8 <= 0) { error_setg(&error_fatal,
"not able to locate clock handle %d in host device tree",
VAR_2); } VAR_4 = g_malloc(VAR_10); while ((VAR_7 = fdt_get_path(VAR_0, VAR_8, VAR_4, VAR_10))
== -FDT_ERR_NOSPACE) { VAR_10 += 16; VAR_4 = g_realloc(VAR_4, VAR_10); } if (VAR_7 < 0) { error_setg(&error_fatal,
"not able to retrieve node path for clock handle %d",
VAR_2); } VAR_6 = qemu_fdt_getprop(VAR_0, VAR_4, "compatible", &VAR_9,
&error_fatal); if (strcmp(VAR_6, "fixed-clock")) { error_setg(&error_fatal,
"clock handle %d is not a fixed clock", VAR_2); } VAR_5 = strrchr(VAR_4, '/'); qemu_fdt_add_subnode(VAR_1, VAR_5); copy_properties_from_host(clock_copied_properties,
ARRAY_SIZE(clock_copied_properties),
VAR_0, VAR_1,
VAR_4, VAR_5); qemu_fdt_setprop_cell(VAR_1, VAR_5, "phandle", VAR_3); g_free(VAR_4); }