From cb84e2c41d96ea99b11212cf9d3ac8b44d0599d4 Mon Sep 17 00:00:00 2001 From: armink Date: Sun, 19 Nov 2023 11:34:48 +0800 Subject: [PATCH] [fdb] Improve FDB_ALIGN_DOWN macro. The align input parameter NOT depends on 2^N align number. --- inc/fdb_low_lvl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/fdb_low_lvl.h b/inc/fdb_low_lvl.h index 888fe89..e6f6ff4 100644 --- a/inc/fdb_low_lvl.h +++ b/inc/fdb_low_lvl.h @@ -36,7 +36,7 @@ * Return the down number of aligned at specified width. RT_ALIGN_DOWN(13, 4) * would return 12. */ -#define FDB_ALIGN_DOWN(size, align) ((size) & ~((align) - 1)) +#define FDB_ALIGN_DOWN(size, align) (((size) / (align)) * (align)) /* align down by write granularity */ #define FDB_WG_ALIGN_DOWN(size) (FDB_ALIGN_DOWN(size, (FDB_WRITE_GRAN + 7)/8))