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>
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 @@
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,