Skip to content

Commit 9a699c0

Browse files
committed
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>
1 parent 0aaa31c commit 9a699c0

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

.wolfssl_known_macro_extras

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ CONFIG_ARCH_CHIP_STM32F746ZG
5252
CONFIG_ARCH_CHIP_STM32H743ZI
5353
CONFIG_ARCH_CHIP_STM32L552ZE
5454
CONFIG_ARCH_POSIX
55+
CONFIG_ARCH_TEGRA
5556
CONFIG_ARM
5657
CONFIG_ARM64
5758
CONFIG_BOARD_NATIVE_POSIX

linuxkm/linuxkm_wc_port.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,7 +1444,12 @@
14441444

14451445
static __always_inline int wc_InitMutex(wolfSSL_Mutex* m)
14461446
{
1447+
/* Tegra vendor kernels do not support assignment of __SPIN_LOCK_UNLOCKED() */
1448+
# ifndef CONFIG_ARCH_TEGRA
14471449
m->lock = __SPIN_LOCK_UNLOCKED(m);
1450+
# else
1451+
spin_lock_init(&m->lock);
1452+
#endif
14481453
m->irq_flags = 0;
14491454

14501455
return 0;

0 commit comments

Comments
 (0)