From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:44621) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RpLIt-0007X9-13 for qemu-devel@nongnu.org; Mon, 23 Jan 2012 09:55:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RpLIm-0004SB-Sh for qemu-devel@nongnu.org; Mon, 23 Jan 2012 09:55:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57421) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RpLIm-0004Rr-JW for qemu-devel@nongnu.org; Mon, 23 Jan 2012 09:55:20 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0NEtJ36025254 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 23 Jan 2012 09:55:19 -0500 From: Gerd Hoffmann Date: Mon, 23 Jan 2012 15:54:53 +0100 Message-Id: <1327330511-16307-8-git-send-email-kraxel@redhat.com> In-Reply-To: <1327330511-16307-1-git-send-email-kraxel@redhat.com> References: <1327330511-16307-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 07/25] usb-uhci: switch to usb_find_device() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Switch over UHCI to use the new usb_find_device() function for device lookup. Signed-off-by: Gerd Hoffmann --- 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 485dc1d..868ac83 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