[PATCH] lib: sbi_scratch: Optimize the alignment code for alloc size

Xiang W wxjstz at 126.com
Thu Mar 9 01:46:07 PST 2023


Signed-off-by: Xiang W <wxjstz at 126.com>
---
 lib/sbi/sbi_scratch.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/sbi/sbi_scratch.c b/lib/sbi/sbi_scratch.c
index 87b34c6..ea62105 100644
--- a/lib/sbi/sbi_scratch.c
+++ b/lib/sbi/sbi_scratch.c
@@ -59,8 +59,7 @@ unsigned long sbi_scratch_alloc_offset(unsigned long size)
 	if (!size)
 		return 0;
 
-	if (size & (__SIZEOF_POINTER__ - 1))
-		size = (size & ~(__SIZEOF_POINTER__ - 1)) + __SIZEOF_POINTER__;
+	size = (size + __SIZEOF_POINTER__ - 1) & ~(__SIZEOF_POINTER__ - 1);
 
 	spin_lock(&extra_lock);
 
-- 
2.39.2




More information about the opensbi mailing list