From 9a699c04ea17f3a0c75fa455ea7f56533c79f14b Mon Sep 17 00:00:00 2001 From: Sameeh Jubran Date: Wed, 26 Nov 2025 05:37:19 +0000 Subject: [PATCH] linuxkm: Fix spinlock initialization on Tegra kernels for __SPIN_LOCK_UNLOCKED macro incompatibility Tegra vendor kernels (L4T / NVIDIA Yocto BSP) fail to compile the wolfSSL Linux kernel module due to the use of the legacy assignment form of the spinlock initializer: m->lock = __SPIN_LOCK_UNLOCKED(m); On Tegra, __SPIN_LOCK_UNLOCKED() expands to a braced-struct initializer that is *not* valid as an assignment expression, causing: error: expected expression before '{' token This patch applies a Tegra-specific workaround by replacing the assignment with the stable kernel API: spin_lock_init(&m->lock); This is guarded behind CONFIG_ARCH_TEGRA so that non-Tegra platforms retain the current initialization behavior until further validation is completed. This fix restores successful kernel module builds on NVIDIA Tegra-based Yocto images without modifying behavior on other architectures. Signed-off-by: Sameeh Jubran --- .wolfssl_known_macro_extras | 1 + linuxkm/linuxkm_wc_port.h | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/.wolfssl_known_macro_extras b/.wolfssl_known_macro_extras index 2c460c174..ca9dc8cce 100644 --- a/.wolfssl_known_macro_extras +++ b/.wolfssl_known_macro_extras @@ -52,6 +52,7 @@ CONFIG_ARCH_CHIP_STM32F746ZG CONFIG_ARCH_CHIP_STM32H743ZI CONFIG_ARCH_CHIP_STM32L552ZE CONFIG_ARCH_POSIX +CONFIG_ARCH_TEGRA CONFIG_ARM CONFIG_ARM64 CONFIG_BOARD_NATIVE_POSIX diff --git a/linuxkm/linuxkm_wc_port.h b/linuxkm/linuxkm_wc_port.h index 834e95819..b5b4e675e 100644 --- a/linuxkm/linuxkm_wc_port.h +++ b/linuxkm/linuxkm_wc_port.h @@ -1444,7 +1444,12 @@ static __always_inline int wc_InitMutex(wolfSSL_Mutex* m) { + /* Tegra vendor kernels do not support assignment of __SPIN_LOCK_UNLOCKED() */ + # ifndef CONFIG_ARCH_TEGRA m->lock = __SPIN_LOCK_UNLOCKED(m); + # else + spin_lock_init(&m->lock); + #endif m->irq_flags = 0; return 0;