diff options
author | Nico Huber <nico.h@gmx.de> | 2020-05-23 18:08:50 +0200 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2022-06-27 13:54:52 +0000 |
commit | b327704a3f6e230c0b51eba63e0e2c3fe64b6923 (patch) | |
tree | a5ffda310ec5333e15748c01334070a5d9b11c4a | |
parent | 9d7728a7d98d0312e309271094fae7df87e76b48 (diff) |
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>
-rw-r--r-- | src/device/resource_allocator_v4.c | 16 |
1 files 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 <memrange.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) { 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, |