summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLi Jinpei <[email protected]>2020-02-11 15:27:49 +0530
committerAnup Patel <[email protected]>2020-02-13 09:10:55 +0530
commit179eddeb9ca5fc1869d40696e0d4cd9899b9d92d (patch)
tree514b5b655908512a5d6352a3bb2427e3897bb84b /lib
parentd6fa7f95bbcaa080810656c79e8879357b312280 (diff)
lib: sbi_scratch: use bitwise ops in sbi_scratch_alloc_offset()
Instead of using loop to make "size" machine word aligned, we should use bitwise ops. Signed-off-by: Li Jinpei <[email protected]> Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]>
Diffstat (limited to 'lib')
-rw-r--r--lib/sbi/sbi_scratch.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/sbi/sbi_scratch.c b/lib/sbi/sbi_scratch.c
index 95ee2f2d..26716c50 100644
--- a/lib/sbi/sbi_scratch.c
+++ b/lib/sbi/sbi_scratch.c
@@ -36,8 +36,8 @@ unsigned long sbi_scratch_alloc_offset(unsigned long size, const char *owner)
if (!size)
return 0;
- while (size & (__SIZEOF_POINTER__ - 1))
- size++;
+ if (size & (__SIZEOF_POINTER__ - 1))
+ size = (size & ~(__SIZEOF_POINTER__ - 1)) + __SIZEOF_POINTER__;
spin_lock(&extra_lock);