static char *spapr_phb_vfio_get_loc_code(sPAPRPHBState *sphb,  PCIDevice *pdev)

{

    char *path = NULL, *buf = NULL, *host = NULL;



    /* Get the PCI VFIO host id */

    host = object_property_get_str(OBJECT(pdev), "host", NULL);

    if (!host) {

        goto err_out;

    }



    /* Construct the path of the file that will give us the DT location */

    path = g_strdup_printf("/sys/bus/pci/devices/%s/devspec", host);

    g_free(host);

    if (!path || !g_file_get_contents(path, &buf, NULL, NULL)) {

        goto err_out;

    }

    g_free(path);



    /* Construct and read from host device tree the loc-code */

    path = g_strdup_printf("/proc/device-tree%s/ibm,loc-code", buf);

    g_free(buf);

    if (!path || !g_file_get_contents(path, &buf, NULL, NULL)) {

        goto err_out;

    }

    return buf;



err_out:

    g_free(path);

    return NULL;

}

static char *spapr_phb_vfio_get_loc_code(sPAPRPHBState *sphb,  PCIDevice *pdev)

{

    char *path = NULL, *buf = NULL, *host = NULL;



    

    host = object_property_get_str(OBJECT(pdev), "host", NULL);

    if (!host) {

        goto err_out;

    }



    

    path = g_strdup_printf("/sys/bus/pci/devices/%s/devspec", host);

    g_free(host);

    if (!path || !g_file_get_contents(path, &buf, NULL, NULL)) {

        goto err_out;

    }

    g_free(path);



    

    path = g_strdup_printf("/proc/device-tree%s/ibm,loc-code", buf);

    g_free(buf);

    if (!path || !g_file_get_contents(path, &buf, NULL, NULL)) {

        goto err_out;

    }

    return buf;



err_out:

    g_free(path);

    return NULL;

}

    if (!path || !g_file_get_contents(path, &buf, NULL, NULL)) {     if (!path || !g_file_get_contents(path, &buf, NULL, NULL)) {
static char *FUNC_0(sPAPRPHBState *VAR_0,  PCIDevice *VAR_1)

{

    char *VAR_2 = NULL, *VAR_3 = NULL, *VAR_4 = NULL;



    

    VAR_4 = object_property_get_str(OBJECT(VAR_1), "VAR_4", NULL);

    if (!VAR_4) {

        goto err_out;

    }



    

    VAR_2 = g_strdup_printf("/sys/bus/pci/devices/%s/devspec", VAR_4);

    g_free(VAR_4);

    if (!VAR_2 || !g_file_get_contents(VAR_2, &VAR_3, NULL, NULL)) {

        goto err_out;

    }

    g_free(VAR_2);



    

    VAR_2 = g_strdup_printf("/proc/device-tree%s/ibm,loc-code", VAR_3);

    g_free(VAR_3);

    if (!VAR_2 || !g_file_get_contents(VAR_2, &VAR_3, NULL, NULL)) {

        goto err_out;

    }

    return VAR_3;



err_out:

    g_free(VAR_2);

    return NULL;

}

static char *FUNC_0(sPAPRPHBState *VAR_0,  PCIDevice *VAR_1)
{ char *VAR_2 = NULL, *VAR_3 = NULL, *VAR_4 = NULL; VAR_4 = object_property_get_str(OBJECT(VAR_1), "VAR_4", NULL); if (!VAR_4) { goto err_out; } VAR_2 = g_strdup_printf("/sys/bus/pci/devices/%s/devspec", VAR_4); g_free(VAR_4); if (!VAR_2 || !g_file_get_contents(VAR_2, &VAR_3, NULL, NULL)) { goto err_out; } g_free(VAR_2); VAR_2 = g_strdup_printf("/proc/device-tree%s/ibm,loc-code", VAR_3); g_free(VAR_3); if (!VAR_2 || !g_file_get_contents(VAR_2, &VAR_3, NULL, NULL)) { goto err_out; } return VAR_3; err_out:
g_free(VAR_2); return NULL; }