summaryrefslogtreecommitdiff
path: root/lib/sbi
diff options
context:
space:
mode:
authorDaniel Schaefer <git@danielschaefer.me>2021-05-13 07:52:35 +0300
committerAnup Patel <anup@brainfault.org>2021-05-14 14:35:20 +0300
commitf90c4c2e0298a6a6e7ade87bf1b704a3a07aa7b9 (patch)
treefa783638405899503e6bf169b88a1ea12906a63c /lib/sbi
parent26998f3d116992ae3fc6670c8f724bcc630d33fd (diff)
downloadopensbi-f90c4c2e0298a6a6e7ade87bf1b704a3a07aa7b9.tar.xz
lib: sbi: Have spinlock checks return bool
spin_lock_check already returned bool in the source file but not in the header. With some toolchains that causes an error, as it should. Because it and related functions all essentially return a bool, we can use this opportunity to change them. Signed-off-by: Daniel Schaefer <git@danielschaefer.me> Reviewed-by: Anup Patel <anup.patel@wdc.com>
Diffstat (limited to 'lib/sbi')
-rw-r--r--lib/sbi/riscv_locks.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/sbi/riscv_locks.c b/lib/sbi/riscv_locks.c
index 75b443b..acab776 100644
--- a/lib/sbi/riscv_locks.c
+++ b/lib/sbi/riscv_locks.c
@@ -8,7 +8,7 @@
#include <sbi/riscv_barrier.h>
#include <sbi/riscv_locks.h>
-static inline int spin_lock_unlocked(spinlock_t lock)
+static inline bool spin_lock_unlocked(spinlock_t lock)
{
return lock.owner == lock.next;
}
@@ -19,7 +19,7 @@ bool spin_lock_check(spinlock_t *lock)
return !spin_lock_unlocked(*lock);
}
-int spin_trylock(spinlock_t *lock)
+bool spin_trylock(spinlock_t *lock)
{
unsigned long inc = 1u << TICKET_SHIFT;
unsigned long mask = 0xffffu << TICKET_SHIFT;
@@ -42,7 +42,7 @@ int spin_trylock(spinlock_t *lock)
: "r"(inc), "r"(mask), "I"(TICKET_SHIFT)
: "memory");
- return !l0;
+ return l0 == 0;
}
void spin_lock(spinlock_t *lock)