Yu-Ping Wu has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/85312?usp=email )
Change subject: commonlib/bsd/mem_chip_info: Add mem_chip_info_entry_density_bytes ......................................................................
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 yupingso@chromium.org --- M src/commonlib/bsd/include/commonlib/bsd/mem_chip_info.h 1 file changed, 8 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/12/85312/1
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 f191cc7..2813651 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 @@ 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; }