diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2013-01-24 15:38:23 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2013-02-19 12:30:05 +0100 |
commit | 6a98d1c0f9e4f6a95d6ecd730ae6fdc70d15c73f (patch) | |
tree | 5f4b6175a96eadfb4684f05a9c8028fa771046c7 /hw/usb/core.c | |
parent | e382d966d06d2989fc28eec8cfdcc2fd99ebfbb7 (diff) |
usb: make usb_packet_copy operate on combined packets
Likewise usb_packet_skip.
Also usb_packet_size.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/usb/core.c')
-rw-r--r-- | hw/usb/core.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/hw/usb/core.c b/hw/usb/core.c index 5517797c8a..674fef8d21 100644 --- a/hw/usb/core.c +++ b/hw/usb/core.c @@ -570,15 +570,17 @@ void usb_packet_addbuf(USBPacket *p, void *ptr, size_t len) void usb_packet_copy(USBPacket *p, void *ptr, size_t bytes) { + QEMUIOVector *iov = p->combined ? &p->combined->iov : &p->iov; + assert(p->actual_length >= 0); - assert(p->actual_length + bytes <= p->iov.size); + assert(p->actual_length + bytes <= iov->size); switch (p->pid) { case USB_TOKEN_SETUP: case USB_TOKEN_OUT: - iov_to_buf(p->iov.iov, p->iov.niov, p->actual_length, ptr, bytes); + iov_to_buf(iov->iov, iov->niov, p->actual_length, ptr, bytes); break; case USB_TOKEN_IN: - iov_from_buf(p->iov.iov, p->iov.niov, p->actual_length, ptr, bytes); + iov_from_buf(iov->iov, iov->niov, p->actual_length, ptr, bytes); break; default: fprintf(stderr, "%s: invalid pid: %x\n", __func__, p->pid); @@ -589,14 +591,21 @@ void usb_packet_copy(USBPacket *p, void *ptr, size_t bytes) void usb_packet_skip(USBPacket *p, size_t bytes) { + QEMUIOVector *iov = p->combined ? &p->combined->iov : &p->iov; + assert(p->actual_length >= 0); - assert(p->actual_length + bytes <= p->iov.size); + assert(p->actual_length + bytes <= iov->size); if (p->pid == USB_TOKEN_IN) { - iov_memset(p->iov.iov, p->iov.niov, p->actual_length, 0, bytes); + iov_memset(iov->iov, iov->niov, p->actual_length, 0, bytes); } p->actual_length += bytes; } +size_t usb_packet_size(USBPacket *p) +{ + return p->combined ? p->combined->iov.size : p->iov.size; +} + void usb_packet_cleanup(USBPacket *p) { assert(!usb_packet_is_inflight(p)); |