[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-trivial] [PATCH v3 10/41] hw/smbios: Use the BYTE-based definition
From: |
Philippe Mathieu-Daudé |
Subject: |
[Qemu-trivial] [PATCH v3 10/41] hw/smbios: Use the BYTE-based definitions |
Date: |
Sun, 15 Apr 2018 20:42:36 -0300 |
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é <address@hidden>
---
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..a72f35d9f5 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, K_BYTE) / K_BYTE;
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, M_BYTE) / M_BYTE;
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 / K_BYTE;
+ end_kb = end / K_BYTE;
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 * G_BYTE)
#define GET_DIMM_SZ ((i < dimm_cnt - 1) ? MAX_DIMM_SZ \
: ((ram_size - 1) % MAX_DIMM_SZ) + 1)
--
2.17.0
- Re: [Qemu-trivial] [PATCH v3 01/41] hw: Clean "hw/devices.h" includes, (continued)
- [Qemu-trivial] [PATCH v3 02/41] hw: Do not include "sysemu/block-backend.h" if it is not necessary, Philippe Mathieu-Daudé, 2018/04/15
- [Qemu-trivial] [PATCH v3 03/41] hw/block/nvme: Include the "qemu/cutils.h" in the source file, Philippe Mathieu-Daudé, 2018/04/15
- [Qemu-trivial] [PATCH v3 04/41] hw/misc/mips_itu: Sort includes, Philippe Mathieu-Daudé, 2018/04/15
- [Qemu-trivial] [PATCH v3 05/41] hw/mips/r4k: Constify params_size, Philippe Mathieu-Daudé, 2018/04/15
- [Qemu-trivial] [PATCH v3 06/41] cutils: Extract byte-based definitions into a new header: "qemu/units.h", Philippe Mathieu-Daudé, 2018/04/15
- [Qemu-trivial] [PATCH v3 07/41] hw/ivshmem: Use the BYTE-based definitions, Philippe Mathieu-Daudé, 2018/04/15
- [Qemu-trivial] [PATCH v3 08/41] hw/ipack: Use the BYTE-based definitions, Philippe Mathieu-Daudé, 2018/04/15
- [Qemu-trivial] [PATCH v3 09/41] hw/scsi: Use the BYTE-based definitions, Philippe Mathieu-Daudé, 2018/04/15
- [Qemu-trivial] [PATCH v3 10/41] hw/smbios: Use the BYTE-based definitions,
Philippe Mathieu-Daudé <=
- [Qemu-trivial] [PATCH v3 11/41] hw/xen: Use the BYTE-based definitions, Philippe Mathieu-Daudé, 2018/04/15
- [Qemu-trivial] [PATCH v3 12/41] hw/tpm: Use the BYTE-based definitions, Philippe Mathieu-Daudé, 2018/04/15
- [Qemu-trivial] [PATCH v3 13/41] hw/block: Use the BYTE-based definitions, Philippe Mathieu-Daudé, 2018/04/15
- [Qemu-trivial] [PATCH v3 15/41] hw/misc: Use the BYTE-based definitions, Philippe Mathieu-Daudé, 2018/04/15
- [Qemu-trivial] [PATCH v3 16/41] hw/riscv: Use the BYTE-based definitions, Philippe Mathieu-Daudé, 2018/04/15
- [Qemu-trivial] [PATCH v3 17/41] hw/m68k: Use the BYTE-based definitions, Philippe Mathieu-Daudé, 2018/04/15
- [Qemu-trivial] [PATCH v3 18/41] hw/sparc: Use the BYTE-based definitions, Philippe Mathieu-Daudé, 2018/04/15
- [Qemu-trivial] [PATCH v3 19/41] hw/s390x: Use the BYTE-based definitions, Philippe Mathieu-Daudé, 2018/04/15
- [Qemu-trivial] [PATCH v3 21/41] hw/xtensa: Use the BYTE-based definitions, Philippe Mathieu-Daudé, 2018/04/15