lib: sbi_scratch: Optimize the alignment code for alloc size
authorXiang W <wxjstz@126.com>
Thu, 9 Mar 2023 10:35:28 +0000 (18:35 +0800)
committerAnup Patel <anup@brainfault.org>
Thu, 6 Apr 2023 10:30:45 +0000 (16:00 +0530)
Signed-off-by: Xiang W <wxjstz@126.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
lib/sbi/sbi_scratch.c

index 87b34c6d4deb5dc4f30ff7601cf5f668b514f7ac..55ebdbb76a8ecc8c82f80b5b4bbc2c03eb4851f6 100644 (file)
@@ -59,8 +59,8 @@ 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 += __SIZEOF_POINTER__ - 1;
+       size &= ~((unsigned long)__SIZEOF_POINTER__ - 1);
 
        spin_lock(&extra_lock);