mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 05:16:47 +08:00
modifyreg16: use small lock in modifyreg16
reason: We would like to replace the big lock with a small lock. Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
@@ -31,9 +31,16 @@
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/spinlock.h>
|
||||
|
||||
#include "misoc.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static spinlock_t g_modifyreg_lock = SP_UNLOCKED;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@@ -51,10 +58,10 @@ void modifyreg16(unsigned int addr, uint16_t clearbits, uint16_t setbits)
|
||||
irqstate_t flags;
|
||||
uint16_t regval;
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&g_modifyreg_lock);
|
||||
regval = getreg16(addr);
|
||||
regval &= ~clearbits;
|
||||
regval |= setbits;
|
||||
putreg16(regval, addr);
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&g_modifyreg_lock, flags);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user