From patchwork Fri Dec 14 13:35:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 206494 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 78BAF2C0098 for ; Sat, 15 Dec 2012 01:03:02 +1100 (EST) Received: from localhost ([::1]:45694 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjVqu-0004oc-L0 for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2012 09:03:00 -0500 Received: from eggs.gnu.org ([208.118.235.92]:45368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjVOv-0004c3-1y for qemu-devel@nongnu.org; Fri, 14 Dec 2012 08:34:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TjVOt-0005Nb-AV for qemu-devel@nongnu.org; Fri, 14 Dec 2012 08:34:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:62197) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjVOs-0005N7-HK for qemu-devel@nongnu.org; Fri, 14 Dec 2012 08:34:03 -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 qBEDY1t4021647 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 14 Dec 2012 08:34:01 -0500 Received: from shalem.localdomain.com (vpn1-6-137.ams2.redhat.com [10.36.6.137]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qBEDXST4028567; Fri, 14 Dec 2012 08:34:00 -0500 From: Hans de Goede To: Gerd Hoffmann Date: Fri, 14 Dec 2012 14:35:45 +0100 Message-Id: <1355492147-5023-25-git-send-email-hdegoede@redhat.com> In-Reply-To: <1355492147-5023-1-git-send-email-hdegoede@redhat.com> References: <1355492147-5023-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Hans de Goede , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 24/26] usbredir: Add usbredir_init_endpoints() helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Hans de Goede --- hw/usb/redirect.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index f4715f3..b3a96f7 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -1086,6 +1086,17 @@ static void usbredir_vm_state_change(void *priv, int running, RunState state) } } +static void usbredir_init_endpoints(USBRedirDevice *dev) +{ + int i; + + usb_ep_init(&dev->dev); + memset(dev->endpoint, 0, sizeof(dev->endpoint)); + for (i = 0; i < MAX_ENDPOINTS; i++) { + QTAILQ_INIT(&dev->endpoint[i].bufpq); + } +} + static int usbredir_initfn(USBDevice *udev) { USBRedirDevice *dev = DO_UPCAST(USBRedirDevice, dev, udev); @@ -1112,9 +1123,7 @@ static int usbredir_initfn(USBDevice *udev) packet_id_queue_init(&dev->cancelled, dev, "cancelled"); packet_id_queue_init(&dev->already_in_flight, dev, "already-in-flight"); - for (i = 0; i < MAX_ENDPOINTS; i++) { - QTAILQ_INIT(&dev->endpoint[i].bufpq); - } + usbredir_init_endpoints(dev); /* We'll do the attach once we receive the speed from the usb-host */ udev->auto_attach = 0; @@ -1317,7 +1326,6 @@ static void usbredir_device_connect(void *priv, static void usbredir_device_disconnect(void *priv) { USBRedirDevice *dev = priv; - int i; /* Stop any pending attaches */ qemu_del_timer(dev->attach_timer); @@ -1334,11 +1342,7 @@ static void usbredir_device_disconnect(void *priv) /* Reset state so that the next dev connected starts with a clean slate */ usbredir_cleanup_device_queues(dev); - memset(dev->endpoint, 0, sizeof(dev->endpoint)); - for (i = 0; i < MAX_ENDPOINTS; i++) { - QTAILQ_INIT(&dev->endpoint[i].bufpq); - } - usb_ep_init(&dev->dev); + usbredir_init_endpoints(dev); dev->interface_info.interface_count = NO_INTERFACE_INFO; dev->dev.addr = 0; dev->dev.speed = 0;