summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafał Miłecki <[email protected]>2026-02-21 11:00:08 +0100
committerTom Rini <[email protected]>2026-03-06 10:32:41 -0600
commit2f28f4116a173891f5c88e1ae3de374241bb1121 (patch)
tree27348b3f67319c0b04af210d43771d81705965d4
parentd80d88cb87d7f291c7abc9168d69f30f994b852f (diff)
fw_env: add ROUND_UP() helper
We already have DIV_ROUND_UP() to simplify code so add ROUND_UP() as well. This makes code in flash_write_buf() easier to follow. Signed-off-by: Rafał Miłecki <[email protected]>
-rw-r--r--tools/env/fw_env.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index fcbe09ea981..c369bda1b85 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -50,6 +50,7 @@ struct env_opts default_opts = {
};
#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
+#define ROUND_UP(x, y) (DIV_ROUND_UP(x, y) * (y))
#define min(x, y) ({ \
typeof(x) _min1 = (x); \
@@ -1027,8 +1028,7 @@ static int flash_write_buf(int dev, int fd, void *buf, size_t count)
* to the start of the data, then count bytes of data, and
* to the end of the block
*/
- write_total = ((block_seek + count + blocklen - 1) /
- blocklen) * blocklen;
+ write_total = ROUND_UP(block_seek + count, blocklen);
}
/*