From: Christoph Muellner <cmuellner@linux.com>
To: opensbi@lists.infradead.org
Subject: [PATCH v3 2/3] spinlocks: Allow direct initialization via SPIN_LOCK_INIT()
Date: Tue, 6 Apr 2021 03:53:53 +0200 [thread overview]
Message-ID: <20210406015354.332780-3-cmuellner@linux.com> (raw)
In-Reply-To: <20210406015354.332780-1-cmuellner@linux.com>
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>
---
include/sbi/riscv_locks.h | 2 +-
lib/sbi/sbi_fifo.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/sbi/riscv_locks.h b/include/sbi/riscv_locks.h
index 55da7c0..faa9676 100644
--- a/include/sbi/riscv_locks.h
+++ b/include/sbi/riscv_locks.h
@@ -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 \
{ \
diff --git a/lib/sbi/sbi_fifo.c b/lib/sbi/sbi_fifo.c
index 8d1dbf0..2a5c012 100644
--- a/lib/sbi/sbi_fifo.c
+++ b/lib/sbi/sbi_fifo.c
@@ -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);
}
--
2.30.2
next prev parent reply other threads:[~2021-04-06 1:53 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-06 1:53 [PATCH v3 0/3] spinlocks: Replace test-and-set locks by ticket locks Christoph Muellner
2021-04-06 1:53 ` [PATCH v3 1/3] include: types: Add __aligned(x) to define the minimum alignement Christoph Muellner
2021-04-06 5:05 ` Anup Patel
2021-04-09 13:46 ` Anup Patel
2021-04-06 1:53 ` Christoph Muellner [this message]
2021-04-06 5:06 ` [PATCH v3 2/3] spinlocks: Allow direct initialization via SPIN_LOCK_INIT() Anup Patel
2021-04-09 13:47 ` Anup Patel
2021-04-06 1:53 ` [PATCH v3 3/3] spinlocks: Replace test-and-set locks by ticket locks Christoph Muellner
2021-04-06 3:14 ` Xiang W
2021-04-06 5:04 ` Anup Patel
2021-04-06 5:08 ` Anup Patel
2021-04-06 5:49 ` Xiang W
2021-04-09 13:47 ` Anup Patel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210406015354.332780-3-cmuellner@linux.com \
--to=cmuellner@linux.com \
--cc=opensbi@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox