This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch releases/12.8
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/releases/12.8 by this push:
     new ecab220c39 max32660_rtc: use small lock in 
arch/arm/src/max326xx/max32660/max32660_rtc.c
ecab220c39 is described below

commit ecab220c3993fb096f4a340778ad40aebfb8a180
Author: hujun5 <huj...@xiaomi.com>
AuthorDate: Mon Dec 9 21:15:52 2024 +0800

    max32660_rtc: use small lock in 
arch/arm/src/max326xx/max32660/max32660_rtc.c
    
    reason:
    We hope to remove all instances of spin_lock_irqsave(NULL).
    
    Signed-off-by: hujun5 <huj...@xiaomi.com>
---
 arch/arm/src/max326xx/max32660/max32660_rtc.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/arm/src/max326xx/max32660/max32660_rtc.c 
b/arch/arm/src/max326xx/max32660/max32660_rtc.c
index e33cd2ec41..ce736f2fbd 100644
--- a/arch/arm/src/max326xx/max32660/max32660_rtc.c
+++ b/arch/arm/src/max326xx/max32660/max32660_rtc.c
@@ -80,6 +80,8 @@ static alm_callback_t g_alarmcb;
 static void *g_alarmarg;
 #endif
 
+static spinlock_t lock = SP_UNLOCKED;
+
 /****************************************************************************
  * Public Data
  ****************************************************************************/
@@ -459,7 +461,7 @@ int up_rtc_settime(const struct timespec *tp)
 
   /* Enable write access to RTC configuration registers */
 
-  flags = spin_lock_irqsave(NULL);
+  flags = spin_lock_irqsave(&lock);
   max326_rtc_wrenable(true);
 
   /* We need to disable the RTC in order to write to the SEC and SSEC
@@ -483,7 +485,7 @@ int up_rtc_settime(const struct timespec *tp)
   max326_rtc_enable(true);
   max326_rtc_wrenable(false);
 
-  spin_unlock_irqrestore(NULL, flags);
+  spin_unlock_irqrestore(&lock, flags);
   return OK;
 }
 
@@ -522,7 +524,7 @@ int max326_rtc_setalarm(struct timespec *ts,
 
   /* Is there already something waiting on the ALARM? */
 
-  flags = spin_lock_irqsave(NULL);
+  flags = spin_lock_irqsave(&lock);
   if (g_alarmcb == NULL)
     {
       /* Get the time as a fixed precision number.
@@ -617,7 +619,7 @@ int max326_rtc_setalarm(struct timespec *ts,
     }
 
 errout_with_lock:
-  spin_unlock_irqrestore(NULL, flags);
+  spin_unlock_irqrestore(&lock, flags);
   return ret;
 }
 #endif
@@ -717,7 +719,7 @@ int max326_rtc_cancelalarm(void)
   uint32_t regval;
   int ret = -ENODATA;
 
-  flags = spin_lock_irqsave(NULL);
+  flags = spin_lock_irqsave(&lock);
 
   if (g_alarmcb != NULL)
     {
@@ -745,7 +747,7 @@ int max326_rtc_cancelalarm(void)
       ret = OK;
     }
 
-  spin_unlock_irqrestore(NULL, flags);
+  spin_unlock_irqrestore(&lock, flags);
   return ret;
 }
 #endif

Reply via email to