[PATCH] platform/mellanox: mlxbf-tmfifo: fix building with CONFIG_SMP=n
From: Arnd Bergmann
Date: Mon Sep 28 2026 - 11:00:27 EST
From: Arnd Bergmann <arnd@xxxxxxxx>
spinlock_t is an empty struct, which makes ARRAY_SIZE() on an
array of them undefined:
drivers/platform/mellanox/mlxbf-tmfifo.c: In function 'mlxbf_tmfifo_virtio_synchronize_cbs':
include/linux/array_size.h:11:38: error: division by zero [-Werror=div-by-zero]
11 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
| ^
drivers/platform/mellanox/mlxbf-tmfifo.c:1146:25: note: in expansion of macro 'ARRAY_SIZE'
1146 | for (i = 0; i < ARRAY_SIZE(fifo->spin_lock); i++) {
| ^~~~~~~~~~
Open-code the size of the array here as is done explicitly elsewhere.
Fixes: 961d62a3c153 ("platform/mellanox: mlxbf-tmfifo: implement synchronize_cbs()")
Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
---
drivers/platform/mellanox/mlxbf-tmfifo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/platform/mellanox/mlxbf-tmfifo.c b/drivers/platform/mellanox/mlxbf-tmfifo.c
index d67215df7371..dc4060c720f8 100644
--- a/drivers/platform/mellanox/mlxbf-tmfifo.c
+++ b/drivers/platform/mellanox/mlxbf-tmfifo.c
@@ -1143,7 +1143,7 @@ static void mlxbf_tmfifo_virtio_synchronize_cbs(struct virtio_device *vdev)
unsigned long flags;
int i;
- for (i = 0; i < ARRAY_SIZE(fifo->spin_lock); i++) {
+ for (i = 0; i < 2; i++) {
spin_lock_irqsave(&fifo->spin_lock[i], flags);
spin_unlock_irqrestore(&fifo->spin_lock[i], flags);
}
--
2.53.0