From d2deb14fb00f71fca4897e44b4d61d8027d2bdf3 Mon Sep 17 00:00:00 2001 From: Yu-Ping Wu Date: Tue, 26 Nov 2024 10:03:27 +0800 Subject: commonlib/bsd/mem_chip_info: Add mem_chip_info_entry_density_bytes Add a helper function to get the mem_chip_info entry size. Change-Id: Ibf2a2006fb3e7772688b80807589e8f2d64d1147 Signed-off-by: Yu-Ping Wu Reviewed-on: https://review.coreboot.org/c/coreboot/+/85312 Tested-by: build bot (Jenkins) Reviewed-by: Yidi Lin --- src/commonlib/bsd/include/commonlib/bsd/mem_chip_info.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/commonlib/bsd/include') diff --git a/src/commonlib/bsd/include/commonlib/bsd/mem_chip_info.h b/src/commonlib/bsd/include/commonlib/bsd/mem_chip_info.h index f191cc7642..2813651b31 100644 --- a/src/commonlib/bsd/include/commonlib/bsd/mem_chip_info.h +++ b/src/commonlib/bsd/include/commonlib/bsd/mem_chip_info.h @@ -98,16 +98,19 @@ static inline size_t mem_chip_info_size(int entries) return sizeof(struct mem_chip_info) + sizeof(struct mem_chip_entry) * entries; }; +static inline uint64_t mem_chip_info_entry_density_bytes(const struct mem_chip_entry *entry) +{ + return (uint64_t)entry->density_mbits * (entry->channel_io_width / entry->io_width) + * (MiB / 8); +} + static inline uint64_t mem_chip_info_total_density_bytes(const struct mem_chip_info *info) { uint64_t bytes = 0; int i; - for (i = 0; i < info->num_entries; i++) { - const struct mem_chip_entry *e = &info->entries[i]; - bytes += (uint64_t)e->density_mbits * (e->channel_io_width / e->io_width) - * (MiB / 8); - } + for (i = 0; i < info->num_entries; i++) + bytes += mem_chip_info_entry_density_bytes(&info->entries[i]); return bytes; } -- cgit v1.2.3