aboutsummaryrefslogtreecommitdiff
path: root/hw/usb/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/usb/core.c')
-rw-r--r--hw/usb/core.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/hw/usb/core.c b/hw/usb/core.c
index 2da38e7fd..b9f1f7a8b 100644
--- a/hw/usb/core.c
+++ b/hw/usb/core.c
@@ -398,9 +398,11 @@ int usb_handle_packet(USBDevice *dev, USBPacket *p)
* When pipelining is enabled usb-devices must always return async,
* otherwise packets can complete out of order!
*/
- assert(!p->ep->pipeline);
- p->result = ret;
- usb_packet_set_state(p, USB_PACKET_COMPLETE);
+ assert(!p->ep->pipeline || QTAILQ_EMPTY(&p->ep->queue));
+ if (ret != USB_RET_NAK) {
+ p->result = ret;
+ usb_packet_set_state(p, USB_PACKET_COMPLETE);
+ }
}
} else {
ret = USB_RET_ASYNC;
@@ -724,3 +726,18 @@ void usb_ep_set_pipeline(USBDevice *dev, int pid, int ep, bool enabled)
struct USBEndpoint *uep = usb_ep_get(dev, pid, ep);
uep->pipeline = enabled;
}
+
+USBPacket *usb_ep_find_packet_by_id(USBDevice *dev, int pid, int ep,
+ uint64_t id)
+{
+ struct USBEndpoint *uep = usb_ep_get(dev, pid, ep);
+ USBPacket *p;
+
+ while ((p = QTAILQ_FIRST(&uep->queue)) != NULL) {
+ if (p->id == id) {
+ return p;
+ }
+ }
+
+ return NULL;
+}