Blame 0128-usb-core-Add-a-usb_ep_find_packet_by_id-helper-funct.patch

5544c1
From 3c2f94fdc5e776ee66bccc704884f3b1b090b4c6 Mon Sep 17 00:00:00 2001
c8dfc6
From: Hans de Goede <hdegoede@redhat.com>
c8dfc6
Date: Tue, 28 Aug 2012 09:43:18 +0200
5544c1
Subject: [PATCH] usb-core: Add a usb_ep_find_packet_by_id() helper function
c8dfc6
c8dfc6
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
c8dfc6
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
5544c1
(cherry picked from commit c13a9e61366cc3e28299d8faeb65e65c6e5964cf)
5544c1
5544c1
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
c8dfc6
---
c8dfc6
 hw/usb.h      |  2 ++
c8dfc6
 hw/usb/core.c | 15 +++++++++++++++
c8dfc6
 2 files changed, 17 insertions(+)
c8dfc6
c8dfc6
diff --git a/hw/usb.h b/hw/usb.h
c8dfc6
index b8fceec..684e3f4 100644
c8dfc6
--- a/hw/usb.h
c8dfc6
+++ b/hw/usb.h
c8dfc6
@@ -377,6 +377,8 @@ void usb_ep_set_max_packet_size(USBDevice *dev, int pid, int ep,
c8dfc6
                                 uint16_t raw);
c8dfc6
 int usb_ep_get_max_packet_size(USBDevice *dev, int pid, int ep);
c8dfc6
 void usb_ep_set_pipeline(USBDevice *dev, int pid, int ep, bool enabled);
c8dfc6
+USBPacket *usb_ep_find_packet_by_id(USBDevice *dev, int pid, int ep,
c8dfc6
+                                    uint64_t id);
c8dfc6
 
c8dfc6
 void usb_attach(USBPort *port);
c8dfc6
 void usb_detach(USBPort *port);
c8dfc6
diff --git a/hw/usb/core.c b/hw/usb/core.c
c8dfc6
index be6d936..fe431d0 100644
c8dfc6
--- a/hw/usb/core.c
c8dfc6
+++ b/hw/usb/core.c
c8dfc6
@@ -726,3 +726,18 @@ void usb_ep_set_pipeline(USBDevice *dev, int pid, int ep, bool enabled)
c8dfc6
     struct USBEndpoint *uep = usb_ep_get(dev, pid, ep);
c8dfc6
     uep->pipeline = enabled;
c8dfc6
 }
c8dfc6
+
c8dfc6
+USBPacket *usb_ep_find_packet_by_id(USBDevice *dev, int pid, int ep,
c8dfc6
+                                    uint64_t id)
c8dfc6
+{
c8dfc6
+    struct USBEndpoint *uep = usb_ep_get(dev, pid, ep);
c8dfc6
+    USBPacket *p;
c8dfc6
+
c8dfc6
+    while ((p = QTAILQ_FIRST(&uep->queue)) != NULL) {
c8dfc6
+        if (p->id == id) {
c8dfc6
+            return p;
c8dfc6
+        }
c8dfc6
+    }
c8dfc6
+
c8dfc6
+    return NULL;
c8dfc6
+}
c8dfc6
-- 
5544c1
1.7.12.1
c8dfc6