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 <sameeh@wolfssl.com>
This commit is contained in:
Sameeh Jubran
2025-11-26 05:37:19 +00:00
committed by sameeh.jubran
parent 0aaa31c438
commit 9a699c04ea
2 changed files with 6 additions and 0 deletions

View File

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

View File

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