From patchwork Sat Jun 30 06:10:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 937331 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ucfwnyvu"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41HkRR2xndz9ry1 for ; Sat, 30 Jun 2018 16:40:35 +1000 (AEST) Received: from localhost ([::1]:45814 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZ9Yf-0004a2-21 for incoming@patchwork.ozlabs.org; Sat, 30 Jun 2018 02:40:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fZ96Q-0004WN-Q9 for qemu-devel@nongnu.org; Sat, 30 Jun 2018 02:11:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fZ96P-0002lR-Jo for qemu-devel@nongnu.org; Sat, 30 Jun 2018 02:11:22 -0400 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]:35839) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fZ96P-0002ie-Ca for qemu-devel@nongnu.org; Sat, 30 Jun 2018 02:11:21 -0400 Received: by mail-wm0-x231.google.com with SMTP id z137-v6so3958813wmc.0 for ; Fri, 29 Jun 2018 23:11:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pvncQlCKHGDnfb6hJ1QULcpk4jCHPUdmU9LPeVGWJpI=; b=ucfwnyvuQJ1gulypWer84UmkiOkM8l7IUDXtXL5HGm7bwYL+HIcpcwZHnhiPWBrEIQ nuWyNs/fAefxIoGjyx6yFQZ/hodUA28Uum46v0BEDz2lhXcQns3pklsqKvNCZMMH1FFX 2HdN6zhlobGhWizAAszjaLm6eEZz/ImzCMxXw/RRG8TCxW8y0aLkxi7G7vvsjthMHN3f j2MB+3HDsqQbp17bsDbE+s9CCdEyaTrbFz6se7yX82U4FvYQvWYblR4uRIvsxoW2KDGu V6p9212pBWSwdn3SM/9gnKlNdGI7ycBDP4VmFR5V1mLVXbae1PP65ACny0Ygrtakt723 FUHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=pvncQlCKHGDnfb6hJ1QULcpk4jCHPUdmU9LPeVGWJpI=; b=BzfpT05lF40eWa0MdArQhqrj5P5dWYvt3P1Ymoti4htUdHBd7a3K+lE6oG1ejxcJFy 34pHf6AYh9CDJWAOz8GybyGhWSJUX0OYZJvuDHzD3GDhIPRNrG/cHTpxrrF4dd1SrdOm xZ+U2FPOAOSgOd/3IL0CY70AXDYMN1HgCY3jASQBvW14Dgn/Idj2zhFrlhn7VrysyJU1 gsDEmZOUi0Wv35/P23KucuRsygVW8oGHEXbDICF534Ye1WSI/k5MTpYNse9C6oIdZVJ/ fqxhacArnyMiAAMFRNoBtqbwJzzUvS9pv/v3QVrcpW16uvC/sIX12wUhHgZyG87qwOKl ehSg== X-Gm-Message-State: APt69E3gnPfy/u+LWm/vBEA2iGdd1LVgC0b4I/eq6fghVBeBixw2d7d8 e8WZvLlSLib9775Uey4qXRVbt/8d X-Google-Smtp-Source: AAOMgpehYTsIuLEHsTDwRmPtp7zKLPquYY64/bBSP9k8Y21V70CFPNHTUkpcxjaPuKOGUIFbBB/N+A== X-Received: by 2002:a1c:46c2:: with SMTP id t185-v6mr3406748wma.56.1530339080157; Fri, 29 Jun 2018 23:11:20 -0700 (PDT) Received: from donizetti.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 24-v6sm563454wrz.94.2018.06.29.23.11.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 29 Jun 2018 23:11:19 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sat, 30 Jun 2018 08:10:29 +0200 Message-Id: <20180630061040.6018-37-pbonzini@redhat.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180630061040.6018-1-pbonzini@redhat.com> References: <20180630061040.6018-1-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::231 Subject: [Qemu-devel] [PULL 36/47] hw/usb: Use the IEC binary prefix definitions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé It eases code review, unit is explicit. Patch generated using: $ git grep -E '(1024|2048|4096|8192|(<<|>>).?(10|20|30))' hw/ include/hw/ and modified manually. Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20180625124238.25339-36-f4bug@amsat.org> Signed-off-by: Paolo Bonzini --- hw/usb/ccid-card-passthru.c | 9 +++++---- hw/usb/combined-packet.c | 3 ++- hw/usb/dev-smartcard-reader.c | 3 ++- hw/usb/redirect.c | 3 ++- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c index 25fb19b..0a6c657 100644 --- a/hw/usb/ccid-card-passthru.c +++ b/hw/usb/ccid-card-passthru.c @@ -9,6 +9,7 @@ */ #include "qemu/osdep.h" +#include "qemu/units.h" #include #include "chardev/char-fe.h" #include "qemu/error-report.h" @@ -40,7 +41,7 @@ static const uint8_t DEFAULT_ATR[] = { 0x13, 0x08 }; -#define VSCARD_IN_SIZE 65536 +#define VSCARD_IN_SIZE (64 * KiB) /* maximum size of ATR - from 7816-3 */ #define MAX_ATR_SIZE 40 @@ -275,9 +276,9 @@ static void ccid_card_vscard_read(void *opaque, const uint8_t *buf, int size) VSCMsgHeader *hdr; if (card->vscard_in_pos + size > VSCARD_IN_SIZE) { - error_report( - "no room for data: pos %d + size %d > %d. dropping connection.", - card->vscard_in_pos, size, VSCARD_IN_SIZE); + error_report("no room for data: pos %u + size %d > %" PRId64 "." + " dropping connection.", + card->vscard_in_pos, size, VSCARD_IN_SIZE); ccid_card_vscard_drop_connection(card); return; } diff --git a/hw/usb/combined-packet.c b/hw/usb/combined-packet.c index 48cac87..01a7ed0 100644 --- a/hw/usb/combined-packet.c +++ b/hw/usb/combined-packet.c @@ -20,6 +20,7 @@ * along with this program; if not, see . */ #include "qemu/osdep.h" +#include "qemu/units.h" #include "qemu-common.h" #include "hw/usb.h" #include "qemu/iov.h" @@ -171,7 +172,7 @@ void usb_ep_combine_input_packets(USBEndpoint *ep) if ((p->iov.size % ep->max_packet_size) != 0 || !p->short_not_ok || next == NULL || /* Work around for Linux usbfs bulk splitting + migration */ - (totalsize == 16348 && p->int_req)) { + (totalsize == (16 * KiB - 36) && p->int_req)) { usb_device_handle_data(ep->dev, first); assert(first->status == USB_RET_ASYNC); if (first->combined) { diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c index 13d0bef..8f716fc 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -35,6 +35,7 @@ */ #include "qemu/osdep.h" +#include "qemu/units.h" #include "qapi/error.h" #include "qemu-common.h" #include "qemu/error-report.h" @@ -63,7 +64,7 @@ do { \ * or handle the migration complexity - VMState doesn't handle this case. * sizes are expected never to be exceeded, unless guest misbehaves. */ -#define BULK_OUT_DATA_SIZE 65536 +#define BULK_OUT_DATA_SIZE (64 * KiB) #define PENDING_ANSWERS_NUM 128 #define BULK_IN_BUF_SIZE 384 diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 58e8f7f..99094a7 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -26,6 +26,7 @@ */ #include "qemu/osdep.h" +#include "qemu/units.h" #include "qapi/error.h" #include "qemu-common.h" #include "qemu/timer.h" @@ -1298,7 +1299,7 @@ static int usbredir_chardev_can_read(void *opaque) } /* usbredir_parser_do_read will consume *all* data we give it */ - return 1024 * 1024; + return 1 * MiB; } static void usbredir_chardev_read(void *opaque, const uint8_t *buf, int size)