boards/boardctl.c: use spinlock IRQ-safe interfaces for consistency

Replace direct up_irq_save/up_irq_restore calls with spinlock IRQ-safe
interfaces (spin_lock_irqsave, spin_trylock_irqsave, spin_unlock_irqrestore)
to maintain semantic consistency when both spinlock and IRQ flags are used together.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
hujun5
2025-07-20 15:05:16 +08:00
committed by Xiang Xiao
parent 0383808b32
commit f4c23eb88b
+30 -25
View File
@@ -804,42 +804,47 @@ int boardctl(unsigned int cmd, uintptr_t arg)
if (spinlock->action == BOARDIOC_SPINLOCK_LOCK)
{
if (flags != NULL)
{
*flags = up_irq_save();
}
if (lock != NULL)
{
spin_lock(lock);
if (flags != NULL)
{
*flags = spin_lock_irqsave(lock);
}
else
{
spin_lock(lock);
}
}
}
else if (spinlock->action == BOARDIOC_SPINLOCK_TRYLOCK)
{
if (flags != NULL)
{
*flags = up_irq_save();
}
if (!spin_trylock(lock))
{
ret = -EBUSY;
if (flags != NULL)
{
up_irq_restore(*flags);
}
}
if (lock != NULL)
{
if (flags != NULL)
{
if (!spin_trylock_irqsave(lock, *flags))
{
ret = -EBUSY;
}
}
else if (!spin_trylock(lock))
{
ret = -EBUSY;
}
}
}
else if (spinlock->action == BOARDIOC_SPINLOCK_UNLOCK)
{
if (flags != NULL)
{
up_irq_restore(*flags);
}
if (lock != NULL)
{
spin_unlock(lock);
if (flags != NULL)
{
spin_unlock_irqrestore(lock, *flags);
}
else
{
spin_unlock(lock);
}
}
}
else