static int ccid_bulk_in_copy_to_guest(USBCCIDState *s, uint8_t *data, int len)

{

    int ret = 0;



    assert(len > 0);

    ccid_bulk_in_get(s);

    if (s->current_bulk_in != NULL) {

        ret = MIN(s->current_bulk_in->len - s->current_bulk_in->pos, len);

        memcpy(data, s->current_bulk_in->data + s->current_bulk_in->pos, ret);

        s->current_bulk_in->pos += ret;

        if (s->current_bulk_in->pos == s->current_bulk_in->len) {

            ccid_bulk_in_release(s);

        }

    } else {

        /* return when device has no data - usb 2.0 spec Table 8-4 */

        ret = USB_RET_NAK;

    }

    if (ret > 0) {

        DPRINTF(s, D_MORE_INFO,

                "%s: %d/%d req/act to guest (BULK_IN)\n", __func__, len, ret);

    }

    if (ret != USB_RET_NAK && ret < len) {

        DPRINTF(s, 1,

            "%s: returning short (EREMOTEIO) %d < %d\n", __func__, ret, len);

    }

    return ret;

}

static int ccid_bulk_in_copy_to_guest(USBCCIDState *s, uint8_t *data, int len)

{

    int ret = 0;



    assert(len > 0);

    ccid_bulk_in_get(s);

    if (s->current_bulk_in != NULL) {

        ret = MIN(s->current_bulk_in->len - s->current_bulk_in->pos, len);

        memcpy(data, s->current_bulk_in->data + s->current_bulk_in->pos, ret);

        s->current_bulk_in->pos += ret;

        if (s->current_bulk_in->pos == s->current_bulk_in->len) {

            ccid_bulk_in_release(s);

        }

    } else {

        

        ret = USB_RET_NAK;

    }

    if (ret > 0) {

        DPRINTF(s, D_MORE_INFO,

                "%s: %d/%d req/act to guest (BULK_IN)\n", __func__, len, ret);

    }

    if (ret != USB_RET_NAK && ret < len) {

        DPRINTF(s, 1,

            "%s: returning short (EREMOTEIO) %d < %d\n", __func__, ret, len);

    }

    return ret;

}

static int ccid_bulk_in_copy_to_guest(USBCCIDState *s, uint8_t *data, int len)     assert(len > 0);         ret = MIN(s->current_bulk_in->len - s->current_bulk_in->pos, len);         memcpy(data, s->current_bulk_in->data + s->current_bulk_in->pos, ret);                 "%s: %d/%d req/act to guest (BULK_IN)\n", __func__, len, ret);     if (ret != USB_RET_NAK && ret < len) {             "%s: returning short (EREMOTEIO) %d < %d\n", __func__, ret, len);
static int FUNC_0(USBCCIDState *VAR_0, uint8_t *VAR_1, int VAR_2)

{

    int VAR_3 = 0;



    assert(VAR_2 > 0);

    ccid_bulk_in_get(VAR_0);

    if (VAR_0->current_bulk_in != NULL) {

        VAR_3 = MIN(VAR_0->current_bulk_in->VAR_2 - VAR_0->current_bulk_in->pos, VAR_2);

        memcpy(VAR_1, VAR_0->current_bulk_in->VAR_1 + VAR_0->current_bulk_in->pos, VAR_3);

        VAR_0->current_bulk_in->pos += VAR_3;

        if (VAR_0->current_bulk_in->pos == VAR_0->current_bulk_in->VAR_2) {

            ccid_bulk_in_release(VAR_0);

        }

    } else {

        

        VAR_3 = USB_RET_NAK;

    }

    if (VAR_3 > 0) {

        DPRINTF(VAR_0, D_MORE_INFO,

                "%VAR_0: %d/%d req/act to guest (BULK_IN)\n", __func__, VAR_2, VAR_3);

    }

    if (VAR_3 != USB_RET_NAK && VAR_3 < VAR_2) {

        DPRINTF(VAR_0, 1,

            "%VAR_0: returning short (EREMOTEIO) %d < %d\n", __func__, VAR_3, VAR_2);

    }

    return VAR_3;

}

static int FUNC_0(USBCCIDState *VAR_0, uint8_t *VAR_1, int VAR_2)
{ int VAR_3 = 0; assert(VAR_2 > 0); ccid_bulk_in_get(VAR_0); if (VAR_0->current_bulk_in != NULL) { VAR_3 = MIN(VAR_0->current_bulk_in->VAR_2 - VAR_0->current_bulk_in->pos, VAR_2); memcpy(VAR_1, VAR_0->current_bulk_in->VAR_1 + VAR_0->current_bulk_in->pos, VAR_3); VAR_0->current_bulk_in->pos += VAR_3; if (VAR_0->current_bulk_in->pos == VAR_0->current_bulk_in->VAR_2) { ccid_bulk_in_release(VAR_0); } } else { VAR_3 = USB_RET_NAK; } if (VAR_3 > 0) { DPRINTF(VAR_0, D_MORE_INFO,
"%VAR_0: %d/%d req/act to guest (BULK_IN)\n", __func__, VAR_2, VAR_3); } if (VAR_3 != USB_RET_NAK && VAR_3 < VAR_2) { DPRINTF(VAR_0, 1,
"%VAR_0: returning short (EREMOTEIO) %d < %d\n", __func__, VAR_3, VAR_2); } return VAR_3; }