From patchwork Mon Jun 11 01:14:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 927455 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=none (p=none dis=none) header.from=amsat.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="R2L2hGLG"; 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 413wGK0NHRz9rvt for ; Mon, 11 Jun 2018 11:21:45 +1000 (AEST) Received: from localhost ([::1]:45694 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSBWg-0000YV-KN for incoming@patchwork.ozlabs.org; Sun, 10 Jun 2018 21:21:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42724) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSBRB-0004yq-OA for qemu-devel@nongnu.org; Sun, 10 Jun 2018 21:16:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fSBRA-0002jH-Mt for qemu-devel@nongnu.org; Sun, 10 Jun 2018 21:16:01 -0400 Received: from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]:41712) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fSBRA-0002iy-IO; Sun, 10 Jun 2018 21:16:00 -0400 Received: by mail-qk0-x242.google.com with SMTP id w23-v6so12067496qkb.8; Sun, 10 Jun 2018 18:16:00 -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=il7wha5HlRd74bIeuuro7pR2rsTDOz8yWq0585fLYxk=; b=R2L2hGLG7efAQLhIYuOS6R+lWFHj6RQ8EFBV694RCsXWLw5H0WJaWmK+LHawVnZeSZ Rzk0SVydrFFZlcVdbdmb7PQOIMyMl89m5DE6Wg+/T6Uy4DA3JUO3NCoPIZ95/SB3f1Cz ALRIBpFuJgjQmL3HNd6mRvq0Iwz/2h18cJtwEDNo5ahQzbDOfeDbnQ3geIXuvV8jr9MM xupQmyzypeG4pNTRamQcT8QFYyg2Ad7BBin7daTmuLnMo3YjAOdGwCLNSk6CXRWwlEUb 1HBG/+kJcXBxYhr+yKkW9T4ocejemMtnWodBv1lTcmq2mtM66o725LwMx+xYVJfT9I+X 9c6w== 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=il7wha5HlRd74bIeuuro7pR2rsTDOz8yWq0585fLYxk=; b=MuA3F5isQEPfgfgqNs4NZgS5V77qlp7lB3IGcz6Z/6qjdn1ffmSB+mOqX3oS9Bcl5h LrIYp/GRg+re9cqlgX21ntKHZzxyCwPnIrnaslJ4G1jyo+CkVoFT6ZVwGCirIM+q2RSa LkuvW/RjYMJI8UO+8RJQoxywswM8SpzV75NZ9j2EYTTC1Q1dp6923MaIxPhXZ9CcQpnX kTALe77sH/556NAZhJ5Bv1E9QTfbJ3LW4mo8Fjw+cSarC3d2pgmotjrCuzK94OZVhu8M Dl08fQ4obHxeAYq/TqPWK1uMiZAlK+d30dH8oetbXbfZrZmSFix7G3V2vWvmhQR3VtDu hxlQ== X-Gm-Message-State: APt69E3pPlrdHCyeDaIHpYnd7n2eYTuBRg2zZi7FSDZCZ3FBKm42b9n/ 7pRbAp7J7z9I5IsI/KDG158= X-Google-Smtp-Source: ADUXVKI9GjuQW5DydehD56PCL/1OIFLc6Alfigm+0zDOUTUttOaJhedCv8GrfHhh9TCdWI+u0cVb6Q== X-Received: by 2002:a37:9543:: with SMTP id x64-v6mr12621121qkd.368.1528679760094; Sun, 10 Jun 2018 18:16:00 -0700 (PDT) Received: from x1.local ([138.117.48.222]) by smtp.gmail.com with ESMTPSA id o5-v6sm28237223qtm.60.2018.06.10.18.15.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Jun 2018 18:15:59 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Thomas Huth , Stefan Weil Date: Sun, 10 Jun 2018 22:14:31 -0300 Message-Id: <20180611011501.10235-11-f4bug@amsat.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180611011501.10235-1-f4bug@amsat.org> References: <20180611011501.10235-1-f4bug@amsat.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::242 Subject: [Qemu-devel] [PATCH v4 10/40] hw/smbios: 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: qemu-trivial@nongnu.org, Igor Mammedov , "Michael S. Tsirkin" , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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é --- hw/smbios/smbios.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 27a07e96f4..a27e54b2fa 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -16,6 +16,7 @@ */ #include "qemu/osdep.h" +#include "qemu/units.h" #include "qapi/error.h" #include "qemu/config-file.h" #include "qemu/error-report.h" @@ -625,10 +626,6 @@ static void smbios_build_type_11_table(void) SMBIOS_BUILD_TABLE_POST; } -#define ONE_KB ((ram_addr_t)1 << 10) -#define ONE_MB ((ram_addr_t)1 << 20) -#define ONE_GB ((ram_addr_t)1 << 30) - #define MAX_T16_STD_SZ 0x80000000 /* 2T in Kilobytes */ static void smbios_build_type_16_table(unsigned dimm_cnt) @@ -640,7 +637,7 @@ static void smbios_build_type_16_table(unsigned dimm_cnt) t->location = 0x01; /* Other */ t->use = 0x03; /* System memory */ t->error_correction = 0x06; /* Multi-bit ECC (for Microsoft, per SeaBIOS) */ - size_kb = QEMU_ALIGN_UP(ram_size, ONE_KB) / ONE_KB; + size_kb = QEMU_ALIGN_UP(ram_size, KiB) / KiB; if (size_kb < MAX_T16_STD_SZ) { t->maximum_capacity = cpu_to_le32(size_kb); t->extended_maximum_capacity = cpu_to_le64(0); @@ -668,7 +665,7 @@ static void smbios_build_type_17_table(unsigned instance, uint64_t size) t->memory_error_information_handle = cpu_to_le16(0xFFFE); /* Not provided */ t->total_width = cpu_to_le16(0xFFFF); /* Unknown */ t->data_width = cpu_to_le16(0xFFFF); /* Unknown */ - size_mb = QEMU_ALIGN_UP(size, ONE_MB) / ONE_MB; + size_mb = QEMU_ALIGN_UP(size, MiB) / MiB; if (size_mb < MAX_T17_STD_SZ) { t->size = cpu_to_le16(size_mb); t->extended_size = cpu_to_le32(0); @@ -707,8 +704,8 @@ static void smbios_build_type_19_table(unsigned instance, end = start + size - 1; assert(end > start); - start_kb = start / ONE_KB; - end_kb = end / ONE_KB; + start_kb = start / KiB; + end_kb = end / KiB; if (start_kb < UINT32_MAX && end_kb < UINT32_MAX) { t->starting_address = cpu_to_le32(start_kb); t->ending_address = cpu_to_le32(end_kb); @@ -869,7 +866,7 @@ void smbios_get_tables(const struct smbios_phys_mem_area *mem_array, smbios_build_type_11_table(); -#define MAX_DIMM_SZ (16ll * ONE_GB) +#define MAX_DIMM_SZ (16 * GiB) #define GET_DIMM_SZ ((i < dimm_cnt - 1) ? MAX_DIMM_SZ \ : ((ram_size - 1) % MAX_DIMM_SZ) + 1)