diff options
author | Anup Patel <apatel@ventanamicro.com> | 2024-07-05 08:51:43 +0530 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2024-07-24 12:18:39 +0530 |
commit | d35c76a7666b5c9681cdac3a48016a74b71c34fd (patch) | |
tree | 3a4370d8d56f9d3564a7d6a96fdff12713c75fd5 | |
parent | 94c3c53a56d32d1d6bf4e015c6266fcb4a80aaad (diff) | |
download | opensbi-d35c76a7666b5c9681cdac3a48016a74b71c34fd.zip opensbi-d35c76a7666b5c9681cdac3a48016a74b71c34fd.tar.gz opensbi-d35c76a7666b5c9681cdac3a48016a74b71c34fd.tar.bz2 |
include: sbi: Add macros to create FIFO as local or global variable
The FIFO data structure is quite handy of variety of use-case so add
SBI_FIFO_INITIALIZER() and SBI_FIFO_DEFINE() helper macros to create
FIFO as local or global variable.
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Reviewed-By: Himanshu Chauhan <hchauhan@ventanamicro.com>
-rw-r--r-- | include/sbi/sbi_fifo.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/sbi/sbi_fifo.h b/include/sbi/sbi_fifo.h index af1632a..89a2ea2 100644 --- a/include/sbi/sbi_fifo.h +++ b/include/sbi/sbi_fifo.h @@ -23,6 +23,18 @@ struct sbi_fifo { u16 tail; }; +#define SBI_FIFO_INITIALIZER(__queue_mem, __entries, __entry_size) \ +{ .queue = __queue_mem, \ + .qlock = SPIN_LOCK_INITIALIZER, \ + .num_entries = __entries, \ + .entry_size = __entry_size, \ + .avail = 0, \ + .tail = 0, \ +} + +#define SBI_FIFO_DEFINE(__name, __queue_mem, __entries, __entry_size) \ +struct sbi_fifo __name = SBI_FIFO_INITIALIZER(__queue_mem, __entries, __entry_size) + enum sbi_fifo_inplace_update_types { SBI_FIFO_SKIP, SBI_FIFO_UPDATED, |