int css_register_io_adapter(CssIoAdapterType type, uint8_t isc, bool swap,

                            bool maskable, uint32_t *id)

{

    IoAdapter *adapter;

    bool found = false;

    int ret;

    S390FLICState *fs = s390_get_flic();

    S390FLICStateClass *fsc = S390_FLIC_COMMON_GET_CLASS(fs);



    *id = 0;

    QTAILQ_FOREACH(adapter, &channel_subsys.io_adapters, sibling) {

        if ((adapter->type == type) && (adapter->isc == isc)) {

            *id = adapter->id;

            found = true;

            ret = 0;

            break;

        }

        if (adapter->id >= *id) {

            *id = adapter->id + 1;

        }

    }

    if (found) {

        goto out;

    }

    adapter = g_new0(IoAdapter, 1);

    ret = fsc->register_io_adapter(fs, *id, isc, swap, maskable);

    if (ret == 0) {

        adapter->id = *id;

        adapter->isc = isc;

        adapter->type = type;

        QTAILQ_INSERT_TAIL(&channel_subsys.io_adapters, adapter, sibling);

    } else {

        g_free(adapter);

        fprintf(stderr, "Unexpected error %d when registering adapter %d\n",

                ret, *id);

    }

out:

    return ret;

}

int css_register_io_adapter(CssIoAdapterType type, uint8_t isc, bool swap,

                            bool maskable, uint32_t *id)

{

    IoAdapter *adapter;

    bool found = false;

    int ret;

    S390FLICState *fs = s390_get_flic();

    S390FLICStateClass *fsc = S390_FLIC_COMMON_GET_CLASS(fs);



    *id = 0;

    QTAILQ_FOREACH(adapter, &channel_subsys.io_adapters, sibling) {

        if ((adapter->type == type) && (adapter->isc == isc)) {

            *id = adapter->id;

            found = true;

            ret = 0;

            break;

        }

        if (adapter->id >= *id) {

            *id = adapter->id + 1;

        }

    }

    if (found) {

        goto out;

    }

    adapter = g_new0(IoAdapter, 1);

    ret = fsc->register_io_adapter(fs, *id, isc, swap, maskable);

    if (ret == 0) {

        adapter->id = *id;

        adapter->isc = isc;

        adapter->type = type;

        QTAILQ_INSERT_TAIL(&channel_subsys.io_adapters, adapter, sibling);

    } else {

        g_free(adapter);

        fprintf(stderr, "Unexpected error %d when registering adapter %d\n",

                ret, *id);

    }

out:

    return ret;

}

int FUNC_0(CssIoAdapterType VAR_0, uint8_t VAR_1, bool VAR_2,

                            bool VAR_3, uint32_t *VAR_4)

{

    IoAdapter *adapter;

    bool found = false;

    int VAR_5;

    S390FLICState *fs = s390_get_flic();

    S390FLICStateClass *fsc = S390_FLIC_COMMON_GET_CLASS(fs);



    *VAR_4 = 0;

    QTAILQ_FOREACH(adapter, &channel_subsys.io_adapters, sibling) {

        if ((adapter->VAR_0 == VAR_0) && (adapter->VAR_1 == VAR_1)) {

            *VAR_4 = adapter->VAR_4;

            found = true;

            VAR_5 = 0;

            break;

        }

        if (adapter->VAR_4 >= *VAR_4) {

            *VAR_4 = adapter->VAR_4 + 1;

        }

    }

    if (found) {

        goto out;

    }

    adapter = g_new0(IoAdapter, 1);

    VAR_5 = fsc->register_io_adapter(fs, *VAR_4, VAR_1, VAR_2, VAR_3);

    if (VAR_5 == 0) {

        adapter->VAR_4 = *VAR_4;

        adapter->VAR_1 = VAR_1;

        adapter->VAR_0 = VAR_0;

        QTAILQ_INSERT_TAIL(&channel_subsys.io_adapters, adapter, sibling);

    } else {

        g_free(adapter);

        fprintf(stderr, "Unexpected error %d when registering adapter %d\n",

                VAR_5, *VAR_4);

    }

out:

    return VAR_5;

}

int FUNC_0(CssIoAdapterType VAR_0, uint8_t VAR_1, bool VAR_2,
bool VAR_3, uint32_t *VAR_4)
{ IoAdapter *adapter; bool found = false; int VAR_5; S390FLICState *fs = s390_get_flic(); S390FLICStateClass *fsc = S390_FLIC_COMMON_GET_CLASS(fs); *VAR_4 = 0; QTAILQ_FOREACH(adapter, &channel_subsys.io_adapters, sibling) { if ((adapter->VAR_0 == VAR_0) && (adapter->VAR_1 == VAR_1)) { *VAR_4 = adapter->VAR_4; found = true; VAR_5 = 0; break; } if (adapter->VAR_4 >= *VAR_4) { *VAR_4 = adapter->VAR_4 + 1; } } if (found) { goto out; } adapter = g_new0(IoAdapter, 1); VAR_5 = fsc->register_io_adapter(fs, *VAR_4, VAR_1, VAR_2, VAR_3); if (VAR_5 == 0) { adapter->VAR_4 = *VAR_4; adapter->VAR_1 = VAR_1; adapter->VAR_0 = VAR_0; QTAILQ_INSERT_TAIL(&channel_subsys.io_adapters, adapter, sibling); } else { g_free(adapter); fprintf(stderr, "Unexpected error %d when registering adapter %d\n",
VAR_5, *VAR_4); } out:
return VAR_5; }