void usb_host_run(struct usb_host_context *context,
                  usb_device_added_cb added_cb,
                  usb_device_removed_cb removed_cb,
                  usb_discovery_done_cb discovery_done_cb,
                  void *client_data)
{
    int done;

    done = usb_host_load(context, added_cb, removed_cb, discovery_done_cb, client_data);

    while (!done) {

        done = usb_host_read_event(context);
    }
} /* usb_host_run() */
/**
 * bus event initialization
 *
 * @param [in] flash
 * @param [in] bb baseband
 * @param [in] mcdr core dump
 *
 * @return a valid bus_ev_hdle_t pointer if succeed
 * @return NULL otherwise
 */
bus_ev_hdle_t *bus_ev_init(link_t *flash, link_t *bb, link_t *mcdr)
{
    bool err = false;
    bool usb = false;
    bus_ev_t *bus_events = NULL;

    ASSERT(flash != NULL);
    ASSERT(bb != NULL);
    ASSERT(mcdr != NULL);

    bus_events = calloc(1, sizeof(bus_ev_t));
    if (!bus_events) {
        LOG_ERROR("memory allocation failed");
        goto err;
    }

    bus_events->wd_fd = CLOSED_FD;

    if (flash->type == E_LINK_USB) {
        usb = true;
        if ((flash->usb.pid != 0) && (flash->usb.vid != 0)) {
            bus_events->modem_flash_pid = flash->usb.pid;
            bus_events->modem_flash_vid = flash->usb.vid;
        } else {
            LOG_ERROR("wrong PID/VID for the flashing interface");
            err = true;
        }
    }

    if (bb->type == E_LINK_USB) {
        usb = true;
        if ((bb->usb.pid != 0) && (bb->usb.vid != 0)) {
            bus_events->modem_bb_pid = bb->usb.pid;
            bus_events->modem_bb_vid = bb->usb.vid;
        } else {
            LOG_ERROR("wrong PID/VID for the baseband interface");
            err = true;
        }
    }

    if (mcdr->type == E_LINK_USB) {
        usb = true;
        if ((mcdr->usb.pid != 0) && (mcdr->usb.vid != 0)) {
            bus_events->mcdr_bb_pid = mcdr->usb.pid;
            bus_events->mcdr_bb_vid = mcdr->usb.vid;
        } else {
            LOG_ERROR("wrong PID/VID for the core dump interface");
            err = true;
        }
    }

    if (usb && !err) {
        if ((bus_events->ctx = usb_host_init()) == NULL)
            goto err;

        /* @TODO: handle errors */
        usb_host_load(bus_events->ctx, device_added_cb, device_rmed_cb, NULL,
                      &bus_events->cli_ctx);
        /* when calling usb_host_load, there's a call to find_existing_devices
        * which triggers added_cb events so, there's been events ... maybe. */
        bus_ev_hdle_events((bus_ev_hdle_t *)bus_events);
    }

    return (bus_ev_hdle_t *)bus_events;

err:
    bus_ev_dispose((bus_ev_hdle_t *)bus_events);
    return NULL;
}