lib: sbi_scratch: Optimize the alignment code for alloc size

Signed-off-by: Xiang W <wxjstz@126.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
Xiang W
2023-03-09 18:35:28 +08:00
committed by Anup Patel
parent c6a092cd80
commit ed88a63b90

View File

@@ -59,8 +59,8 @@ unsigned long sbi_scratch_alloc_offset(unsigned long size)
if (!size) if (!size)
return 0; return 0;
if (size & (__SIZEOF_POINTER__ - 1)) size += __SIZEOF_POINTER__ - 1;
size = (size & ~(__SIZEOF_POINTER__ - 1)) + __SIZEOF_POINTER__; size &= ~((unsigned long)__SIZEOF_POINTER__ - 1);
spin_lock(&extra_lock); spin_lock(&extra_lock);