allocator_v4: Manually inline round()

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 <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/65400
Reviewed-by: Elyes Haouas <ehaouas@noos.fr>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
Nico Huber 2020-05-23 18:08:50 +02:00 committed by Felix Held
parent 9d7728a7d9
commit b327704a3f
1 changed files with 2 additions and 14 deletions

View File

@ -5,18 +5,6 @@
#include <memrange.h> #include <memrange.h>
#include <post.h> #include <post.h>
/**
* 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) static const char *resource2str(const struct resource *res)
{ {
if (res->flags & IORESOURCE_IO) 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 * Alignment value of 0 means that the child resource has no alignment
* requirements and so the base value remains unchanged here. * 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", 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, 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 * the bridge to ensure that the upstream bridge/domain allocates big
* enough window. * 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", 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, dev_path(bridge), resource2str(bridge_res), bridge_res->size,