From b327704a3f6e230c0b51eba63e0e2c3fe64b6923 Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Sat, 23 May 2020 18:08:50 +0200 Subject: [PATCH] allocator_v4: Manually inline round() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While what this round() function does is documented, it still seems hard to follow what happens when reading a call. I tried to come up with a better name, but eventually reading an explicit ALIGN_UP() worked best. Change-Id: Ifd49270bbae0ee463a996643fc76bce1f97ec9b7 Signed-off-by: Nico Huber Reviewed-on: https://review.coreboot.org/c/coreboot/+/65400 Reviewed-by: Elyes Haouas Tested-by: build bot (Jenkins) Reviewed-by: Kyösti Mälkki Reviewed-by: Angel Pons --- src/device/resource_allocator_v4.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/device/resource_allocator_v4.c b/src/device/resource_allocator_v4.c index 5be1dff984..707ccf0a96 100644 --- a/src/device/resource_allocator_v4.c +++ b/src/device/resource_allocator_v4.c @@ -5,18 +5,6 @@ #include #include -/** - * Round a number up to an alignment. - * - * @param val The starting value. - * @param pow Alignment as a power of two. - * @return Rounded up number. - */ -static resource_t round(resource_t val, unsigned long pow) -{ - return ALIGN_UP(val, POWER_OF_2(pow)); -} - static const char *resource2str(const struct resource *res) { if (res->flags & IORESOURCE_IO) @@ -128,7 +116,7 @@ static void update_bridge_resource(const struct device *bridge, struct resource * Alignment value of 0 means that the child resource has no alignment * requirements and so the base value remains unchanged here. */ - base = round(base, child_res->align); + base = ALIGN_UP(base, POWER_OF_2(child_res->align)); res_printk(print_depth + 1, "%s %02lx * [0x%llx - 0x%llx] %s\n", dev_path(child), child_res->index, base, base + child_res->size - 1, @@ -144,7 +132,7 @@ static void update_bridge_resource(const struct device *bridge, struct resource * the bridge to ensure that the upstream bridge/domain allocates big * enough window. */ - bridge_res->size = round(base, bridge_res->gran); + bridge_res->size = ALIGN_UP(base, POWER_OF_2(bridge_res->gran)); res_printk(print_depth, "%s %s: size: %llx align: %d gran: %d limit: %llx done\n", dev_path(bridge), resource2str(bridge_res), bridge_res->size,