All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-trivial@nongnu.org, Thomas Huth <thuth@redhat.com>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	qemu-devel@nongnu.org, "Gerd Hoffmann" <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH v3 34/41] hw/usb: Use the BYTE-based definitions
Date: Sun, 15 Apr 2018 20:43:00 -0300	[thread overview]
Message-ID: <20180415234307.28132-35-f4bug@amsat.org> (raw)
In-Reply-To: <20180415234307.28132-1-f4bug@amsat.org>

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é <f4bug@amsat.org>
---
 hw/usb/ccid-card-passthru.c   | 5 +++--
 hw/usb/combined-packet.c      | 3 ++-
 hw/usb/dev-smartcard-reader.c | 3 ++-
 hw/usb/redirect.c             | 3 ++-
 4 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c
index b7dd3602dc..4bd1e2232e 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 <cacard/vscard_common.h>
 #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 * K_BYTE)
 
 /* maximum size of ATR - from 7816-3 */
 #define MAX_ATR_SIZE        40
@@ -276,7 +277,7 @@ static void ccid_card_vscard_read(void *opaque, const uint8_t *buf, int size)
 
     if (card->vscard_in_pos + size > VSCARD_IN_SIZE) {
         error_report(
-            "no room for data: pos %d +  size %d > %d. dropping connection.",
+            "no room for data: pos %d +  size %d > %llu. 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 48cac87f6a..2f068af927 100644
--- a/hw/usb/combined-packet.c
+++ b/hw/usb/combined-packet.c
@@ -20,6 +20,7 @@
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 #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 * K_BYTE - 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 e6468057a0..0cdee70f82 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 * K_BYTE)
 #define PENDING_ANSWERS_NUM 128
 
 #define BULK_IN_BUF_SIZE 384
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 65a9196c1a..3ed4a39be1 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 * M_BYTE;
 }
 
 static void usbredir_chardev_read(void *opaque, const uint8_t *buf, int size)
-- 
2.17.0

  parent reply	other threads:[~2018-04-15 23:45 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-15 23:42 [Qemu-devel] [PATCH v3 00/41] hw: Use the BYTE-based definitions when useful Philippe Mathieu-Daudé
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 01/41] hw: Clean "hw/devices.h" includes Philippe Mathieu-Daudé
2018-04-16  4:53   ` Thomas Huth
2018-04-16 10:06     ` Philippe Mathieu-Daudé
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 02/41] hw: Do not include "sysemu/block-backend.h" if it is not necessary Philippe Mathieu-Daudé
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 03/41] hw/block/nvme: Include the "qemu/cutils.h" in the source file Philippe Mathieu-Daudé
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 04/41] hw/misc/mips_itu: Sort includes Philippe Mathieu-Daudé
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 05/41] hw/mips/r4k: Constify params_size Philippe Mathieu-Daudé
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 06/41] cutils: Extract byte-based definitions into a new header: "qemu/units.h" Philippe Mathieu-Daudé
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 07/41] hw/ivshmem: Use the BYTE-based definitions Philippe Mathieu-Daudé
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 08/41] hw/ipack: " Philippe Mathieu-Daudé
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 09/41] hw/scsi: " Philippe Mathieu-Daudé
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 10/41] hw/smbios: " Philippe Mathieu-Daudé
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 11/41] hw/xen: " Philippe Mathieu-Daudé
2018-04-15 23:42   ` Philippe Mathieu-Daudé
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 12/41] hw/tpm: " Philippe Mathieu-Daudé
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 13/41] hw/block: " Philippe Mathieu-Daudé
2018-04-15 23:42 ` [PATCH v3 14/41] hw/display: " Philippe Mathieu-Daudé
2018-04-16 20:58   ` [Qemu-devel] [Xen-devel] " Alistair Francis
2018-04-16 20:58     ` Alistair Francis
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 15/41] hw/misc: " Philippe Mathieu-Daudé
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 16/41] hw/riscv: " Philippe Mathieu-Daudé
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 17/41] hw/m68k: " Philippe Mathieu-Daudé
2018-04-16  4:58   ` Thomas Huth
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 18/41] hw/sparc: " Philippe Mathieu-Daudé
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 19/41] hw/s390x: " Philippe Mathieu-Daudé
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 20/41] hw/hppa: " Philippe Mathieu-Daudé
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 21/41] hw/xtensa: " Philippe Mathieu-Daudé
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 22/41] hw/alpha: " Philippe Mathieu-Daudé
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 23/41] hw/tricore: " Philippe Mathieu-Daudé
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 24/41] hw/microblaze: " Philippe Mathieu-Daudé
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 25/41] hw/nios2: " Philippe Mathieu-Daudé
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 26/41] hw/cris: " Philippe Mathieu-Daudé
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 27/41] hw/lm32: " Philippe Mathieu-Daudé
2018-04-16  6:40   ` Michael Walle
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 28/41] hw/sh4: " Philippe Mathieu-Daudé
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 29/41] hw/mips: " Philippe Mathieu-Daudé
2018-04-16 20:56   ` Alistair Francis
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 30/41] hw/arm: " Philippe Mathieu-Daudé
2018-04-15 23:42 ` [Qemu-devel] [PATCH v3 33/41] hw/net: " Philippe Mathieu-Daudé
2018-04-16  5:23   ` Stefan Weil
2018-04-17 16:09     ` Philippe Mathieu-Daudé
2018-04-15 23:43 ` Philippe Mathieu-Daudé [this message]
2018-04-16  8:03   ` [Qemu-devel] [PATCH v3 34/41] hw/usb: " Gerd Hoffmann
2018-04-15 23:43 ` [Qemu-devel] [PATCH v3 35/41] hw/sd: " Philippe Mathieu-Daudé
2018-04-15 23:43 ` [Qemu-devel] [PATCH v3 36/41] hw/vfio: " Philippe Mathieu-Daudé
2018-04-15 23:43 ` [Qemu-devel] [PATCH v3 37/41] hw/virtio: " Philippe Mathieu-Daudé
2018-04-15 23:43 ` [Qemu-devel] [PATCH v3 38/41] hw/rdma: " Philippe Mathieu-Daudé
2018-04-16  4:23   ` Marcel Apfelbaum
2018-04-21 17:55   ` Yuval Shaia
2018-04-15 23:43 ` [Qemu-devel] [PATCH v3 39/41] hw/nvdimm: " Philippe Mathieu-Daudé
2018-04-15 23:43 ` [Qemu-devel] [PATCH v3 40/41] hw/loader: " Philippe Mathieu-Daudé
2018-04-15 23:43 ` [Qemu-devel] [PATCH v3 41/41] cutils: Do not include "qemu/units.h" directly Philippe Mathieu-Daudé
2018-04-16  9:53   ` Marcel Apfelbaum
     [not found] ` <20180415234307.28132-33-f4bug@amsat.org>
2018-04-16  9:52   ` [Qemu-devel] [PATCH v3 32/41] hw/i386: Use the BYTE-based definitions Marcel Apfelbaum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180415234307.28132-35-f4bug@amsat.org \
    --to=f4bug@amsat.org \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.