Received: from eggs.gnu.org ([140.186.70.92]:44596) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RpLIr-0007Sx-0e for qemu-devel@nongnu.org; Mon, 23 Jan 2012 09:55:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RpLIm-0004Rl-2G for qemu-devel@nongnu.org; Mon, 23 Jan 2012 09:55:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58279) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RpLIl-0004Rb-PG for qemu-devel@nongnu.org; Mon, 23 Jan 2012 09:55:20 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0NEtJtT029263 (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:51 +0100 Message-Id: <1327330511-16307-6-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 05/25] usb-hub: implement find_device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Implement the find_device callback for the usb hub. It'll loop over all ports, calling usb_find_device for all enabled ports until it finds a matching device. Signed-off-by: Gerd Hoffmann --- hw/usb-hub.c | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/hw/usb-hub.c b/hw/usb-hub.c index d83cfb5..c9f30d9 100644 --- a/hw/usb-hub.c +++ b/hw/usb-hub.c @@ -220,6 +220,26 @@ static void usb_hub_complete(USBPort *port, USBPacket *packet) s->dev.port->ops->complete(s->dev.port, packet); } +static USBDevice *usb_hub_find_device(USBDevice *dev, uint8_t addr) +{ + USBHubState *s = DO_UPCAST(USBHubState, dev, dev); + USBHubPort *port; + USBDevice *downstream; + int i; + + for (i = 0; i < NUM_PORTS; i++) { + port = &s->ports[i]; + if (!(port->wPortStatus & PORT_STAT_ENABLE)) { + continue; + } + downstream = usb_find_device(&port->port, addr); + if (downstream != NULL) { + return downstream; + } + } + return NULL; +} + static void usb_hub_handle_reset(USBDevice *dev) { USBHubState *s = DO_UPCAST(USBHubState, dev, dev); @@ -541,6 +561,7 @@ static struct USBDeviceInfo hub_info = { .qdev.vmsd = &vmstate_usb_hub, .usb_desc = &desc_hub, .init = usb_hub_initfn, + .find_device = usb_hub_find_device, .handle_packet = usb_hub_handle_packet, .handle_reset = usb_hub_handle_reset, .handle_control = usb_hub_handle_control, -- 1.7.1