From 42ebe289b08f9c9da0ca2b0d0f85f4a9749d704d Mon Sep 17 00:00:00 2001 From: ouyangxiangzhen Date: Wed, 18 Jun 2025 14:14:48 +0800 Subject: [PATCH] spinlock: Remove atomic.h inclusion in spinlock_type.h Since the spinlock_type.h is designed to avoid including atomic.h in the userspace, we should remove `atomic.h` inclusion in spinlock_type.h. Signed-off-by: ouyangxiangzhen --- include/nuttx/spinlock.h | 6 +++--- include/nuttx/spinlock_type.h | 10 +++------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/include/nuttx/spinlock.h b/include/nuttx/spinlock.h index ebca68fbe2..44493a8208 100644 --- a/include/nuttx/spinlock.h +++ b/include/nuttx/spinlock.h @@ -595,8 +595,8 @@ irqstate_t rspin_lock_irqsave(FAR rspinlock_t *lock) /* Try seize the ownership of the lock. */ - while (!atomic_cmpxchg_acquire((atomic_t *)&lock->val, - (atomic_t *)&old_val.val, new_val.val)) + while (!atomic_cmpxchg_acquire((FAR atomic_t *)&lock->val, + (FAR atomic_t *)&old_val.val, new_val.val)) { /* Already owned this lock. */ @@ -821,7 +821,7 @@ void rspin_unlock_irqrestore(FAR rspinlock_t *lock, irqstate_t flags) if (--lock->count == 0) { - atomic_set_release((atomic_t *)&lock->val, 0); + atomic_set_release((FAR atomic_t *)&lock->val, 0); up_irq_restore(flags); } diff --git a/include/nuttx/spinlock_type.h b/include/nuttx/spinlock_type.h index 9d3ac4b34d..0a50c9ed45 100644 --- a/include/nuttx/spinlock_type.h +++ b/include/nuttx/spinlock_type.h @@ -29,10 +29,6 @@ #include -#if defined(CONFIG_RW_SPINLOCK) || defined(CONFIG_TICKET_SPINLOCK) -#include -#endif - #undef EXTERN #if defined(__cplusplus) #define EXTERN extern "C" @@ -43,7 +39,7 @@ extern "C" #endif #if defined(CONFIG_RW_SPINLOCK) -typedef atomic_t rwlock_t; +typedef uint32_t rwlock_t; # define RW_SP_UNLOCKED 0 # define RW_SP_READ_LOCKED 1 # define RW_SP_WRITE_LOCKED -1 @@ -58,8 +54,8 @@ typedef uint8_t spinlock_t; typedef struct spinlock_s { - atomic_t owner; - atomic_t next; + uint32_t owner; + uint32_t next; } spinlock_t; # define SP_UNLOCKED (spinlock_t){0, 0}