From patchwork Thu Jan 24 15:41:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 215370 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 EFFA72C0084 for ; Fri, 25 Jan 2013 02:41:54 +1100 (EST) Received: from localhost ([::1]:51325 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyOw5-0002xd-1E for incoming@patchwork.ozlabs.org; Thu, 24 Jan 2013 10:41:53 -0500 Received: from eggs.gnu.org ([208.118.235.92]:47227) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyOvm-0002sz-47 for qemu-devel@nongnu.org; Thu, 24 Jan 2013 10:41:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TyOvd-00067I-1l for qemu-devel@nongnu.org; Thu, 24 Jan 2013 10:41:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:11585) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyOvc-00066V-NH for qemu-devel@nongnu.org; Thu, 24 Jan 2013 10:41:24 -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 r0OFfOhn017245 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 24 Jan 2013 10:41:24 -0500 Received: from rincewind.home.kraxel.org (ovpn-116-93.ams2.redhat.com [10.36.116.93]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r0OFfNqo021095; Thu, 24 Jan 2013 10:41:23 -0500 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 2A9E940FDE; Thu, 24 Jan 2013 16:41:21 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 24 Jan 2013 16:41:19 +0100 Message-Id: <1359042080-24154-7-git-send-email-kraxel@redhat.com> In-Reply-To: <1359042080-24154-1-git-send-email-kraxel@redhat.com> References: <1359042080-24154-1-git-send-email-kraxel@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: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 6/7] usb-redir: simplify packet copy 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 usb_packet_copy can handle combined packets now, so it isn't needed to special-case them any more. Also use the new usb_packet_size() function. Signed-off-by: Gerd Hoffmann --- hw/usb/redirect.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 8c0ead0..7078403 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -737,7 +737,7 @@ static void usbredir_handle_bulk_data(USBRedirDevice *dev, USBPacket *p, uint8_t ep) { struct usb_redir_bulk_packet_header bulk_packet; - size_t size = (p->combined) ? p->combined->iov.size : p->iov.size; + size_t size = usb_packet_size(p); const int maxp = dev->endpoint[EP2I(ep)].max_packet_size; if (usbredir_already_in_flight(dev, p->id)) { @@ -771,12 +771,7 @@ static void usbredir_handle_bulk_data(USBRedirDevice *dev, USBPacket *p, &bulk_packet, NULL, 0); } else { uint8_t buf[size]; - if (p->combined) { - iov_to_buf(p->combined->iov.iov, p->combined->iov.niov, - 0, buf, size); - } else { - usb_packet_copy(p, buf, size); - } + usb_packet_copy(p, buf, size); usbredir_log_data(dev, "bulk data out:", buf, size); usbredirparser_send_bulk_packet(dev->parser, p->id, &bulk_packet, buf, size); @@ -1830,7 +1825,7 @@ static void usbredir_bulk_packet(void *priv, uint64_t id, p = usbredir_find_packet_by_id(dev, ep, id); if (p) { - size_t size = (p->combined) ? p->combined->iov.size : p->iov.size; + size_t size = usb_packet_size(p); usbredir_handle_status(dev, p, bulk_packet->status); if (data_len > 0) { usbredir_log_data(dev, "bulk data in:", data, data_len); @@ -1840,12 +1835,7 @@ static void usbredir_bulk_packet(void *priv, uint64_t id, p->status = USB_RET_BABBLE; data_len = len = size; } - if (p->combined) { - iov_from_buf(p->combined->iov.iov, p->combined->iov.niov, - 0, data, data_len); - } else { - usb_packet_copy(p, data, data_len); - } + usb_packet_copy(p, data, data_len); } p->actual_length = len; if (p->pid == USB_TOKEN_IN && p->ep->pipeline) {