[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 10/28] usb-uhci: switch to usb_find_device()
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 10/28] usb-uhci: switch to usb_find_device() |
Date: |
Fri, 10 Feb 2012 12:43:06 +0100 |
Switch over UHCI to use the new usb_find_device()
function for device lookup.
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/usb-uhci.c | 45 +++++++++++++++------------------------------
1 files changed, 15 insertions(+), 30 deletions(-)
diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c
index 407e0f3..a1f597a 100644
--- a/hw/usb-uhci.c
+++ b/hw/usb-uhci.c
@@ -94,15 +94,6 @@ static const char *pid2str(int pid)
#define DPRINTF(...)
#endif
-#ifdef DEBUG_DUMP_DATA
-static void dump_data(USBPacket *p, int ret)
-{
- iov_hexdump(p->iov.iov, p->iov.niov, stderr, "uhci", ret);
-}
-#else
-static void dump_data(USBPacket *p, int ret) {}
-#endif
-
typedef struct UHCIState UHCIState;
/*
@@ -643,30 +634,22 @@ static void uhci_wakeup(USBPort *port1)
}
}
-static int uhci_broadcast_packet(UHCIState *s, USBPacket *p)
+static USBDevice *uhci_find_device(UHCIState *s, uint8_t addr)
{
- int i, ret;
-
- DPRINTF("uhci: packet enter. pid %s addr 0x%02x ep %d len %zd\n",
- pid2str(p->pid), p->devaddr, p->devep, p->iov.size);
- if (p->pid == USB_TOKEN_OUT || p->pid == USB_TOKEN_SETUP)
- dump_data(p, 0);
+ USBDevice *dev;
+ int i;
- ret = USB_RET_NODEV;
- for (i = 0; i < NB_PORTS && ret == USB_RET_NODEV; i++) {
+ for (i = 0; i < NB_PORTS; i++) {
UHCIPort *port = &s->ports[i];
- USBDevice *dev = port->port.dev;
-
- if (dev && dev->attached && (port->ctrl & UHCI_PORT_EN)) {
- ret = usb_handle_packet(dev, p);
+ if (!(port->ctrl & UHCI_PORT_EN)) {
+ continue;
+ }
+ dev = usb_find_device(&port->port, addr);
+ if (dev != NULL) {
+ return dev;
}
}
-
- DPRINTF("uhci: packet exit. ret %d len %zd\n", ret, p->iov.size);
- if (p->pid == USB_TOKEN_IN && ret > 0)
- dump_data(p, ret);
-
- return ret;
+ return NULL;
}
static void uhci_async_complete(USBPort *port, USBPacket *packet);
@@ -830,13 +813,15 @@ static int uhci_handle_td(UHCIState *s, uint32_t addr,
UHCI_TD *td, uint32_t *in
switch(pid) {
case USB_TOKEN_OUT:
case USB_TOKEN_SETUP:
- len = uhci_broadcast_packet(s, &async->packet);
+ len = usb_handle_packet(uhci_find_device(s, async->packet.devaddr),
+ &async->packet);
if (len >= 0)
len = max_len;
break;
case USB_TOKEN_IN:
- len = uhci_broadcast_packet(s, &async->packet);
+ len = usb_handle_packet(uhci_find_device(s, async->packet.devaddr),
+ &async->packet);
break;
default:
--
1.7.1
- [Qemu-devel] [PULL 00/28] usb patch queue, Gerd Hoffmann, 2012/02/10
- [Qemu-devel] [PATCH 02/28] usb-ehci: Clear the portstatus powner bit on device disconnect, Gerd Hoffmann, 2012/02/10
- [Qemu-devel] [PATCH 04/28] usb: kill USB_MSG_{ATTACH,DETACH}, Gerd Hoffmann, 2012/02/10
- [Qemu-devel] [PATCH 08/28] usb-hub: implement find_device, Gerd Hoffmann, 2012/02/10
- [Qemu-devel] [PATCH 01/28] usb-uhci: implement bandwidth management, Gerd Hoffmann, 2012/02/10
- [Qemu-devel] [PATCH 07/28] usb: add usb_find_device(), Gerd Hoffmann, 2012/02/10
- [Qemu-devel] [PATCH 22/28] usb: add USBBusOps->wakeup_endpoint, Gerd Hoffmann, 2012/02/10
- [Qemu-devel] [PATCH 10/28] usb-uhci: switch to usb_find_device(),
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 03/28] usb-redir: Add the posibility to filter out certain devices from redirecion, Gerd Hoffmann, 2012/02/10
- [Qemu-devel] [PATCH 18/28] usb: add USBEndpoint->{nr,pid}, Gerd Hoffmann, 2012/02/10
- [Qemu-devel] [PATCH 06/28] usb: kill usb_send_msg, Gerd Hoffmann, 2012/02/10
- [Qemu-devel] [PATCH 14/28] usb-xhci: switch to usb_find_device(), Gerd Hoffmann, 2012/02/10
- [Qemu-devel] [PATCH 23/28] xhci: signal low- and fullspeed support, Gerd Hoffmann, 2012/02/10
- [Qemu-devel] [PATCH 15/28] usb: kill handle_packet callback, Gerd Hoffmann, 2012/02/10
- [Qemu-devel] [PATCH 12/28] usb-ohci: switch to usb_find_device(), Gerd Hoffmann, 2012/02/10
- [Qemu-devel] [PATCH 05/28] usb: kill USB_MSG_RESET, Gerd Hoffmann, 2012/02/10
- [Qemu-devel] [PATCH 16/28] usb: fold usb_generic_handle_packet into usb_handle_packet, Gerd Hoffmann, 2012/02/10
- [Qemu-devel] [PATCH 26/28] xhci: kill port arg from xhci_setup_packet, Gerd Hoffmann, 2012/02/10