include: sbi: Allow direct initialization via SPIN_LOCK_INIT()
authorChristoph Muellner <cmuellner@linux.com>
Tue, 6 Apr 2021 01:53:53 +0000 (03:53 +0200)
committerAnup Patel <anup@brainfault.org>
Fri, 9 Apr 2021 13:09:50 +0000 (18:39 +0530)
The current implementation of SPIN_LOCK_INIT() provides the spinlock
to be initialized as reference. This does not allow a direct
initialization of the spinlock object at the creation site.

Let's pass the spinlock directly instead (like Linux does as well)
and adjust all users of the macro (in fact there is only one user).

Signed-off-by: Christoph Muellner <cmuellner@linux.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
include/sbi/riscv_locks.h
lib/sbi/sbi_fifo.c

index 55da7c0..faa9676 100644 (file)
@@ -16,7 +16,7 @@ typedef struct {
 
 #define __RISCV_SPIN_UNLOCKED 0
 
-#define SPIN_LOCK_INIT(_lptr) (_lptr)->lock = __RISCV_SPIN_UNLOCKED
+#define SPIN_LOCK_INIT(x) (x).lock = __RISCV_SPIN_UNLOCKED
 
 #define SPIN_LOCK_INITIALIZER                  \
        {                                      \
index 8d1dbf0..2a5c012 100644 (file)
@@ -18,7 +18,7 @@ void sbi_fifo_init(struct sbi_fifo *fifo, void *queue_mem, u16 entries,
        fifo->queue       = queue_mem;
        fifo->num_entries = entries;
        fifo->entry_size  = entry_size;
-       SPIN_LOCK_INIT(&fifo->qlock);
+       SPIN_LOCK_INIT(fifo->qlock);
        fifo->avail = fifo->tail = 0;
        sbi_memset(fifo->queue, 0, (size_t)entries * entry_size);
 }