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

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 4ae12851243150012463b4184db39b3e96298b92
Author: Abdelatif Guettouche <[email protected]>
AuthorDate: Thu Sep 9 13:02:04 2021 +0200

    esp32_emac.c: Use device specific locks.
    
    Signed-off-by: Abdelatif Guettouche <[email protected]>
---
 arch/xtensa/src/esp32/esp32_emac.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/xtensa/src/esp32/esp32_emac.c 
b/arch/xtensa/src/esp32/esp32_emac.c
index 97b5575..0ce4e5f 100644
--- a/arch/xtensa/src/esp32/esp32_emac.c
+++ b/arch/xtensa/src/esp32/esp32_emac.c
@@ -44,6 +44,7 @@
 #include <nuttx/wqueue.h>
 #include <nuttx/signal.h>
 #include <nuttx/list.h>
+#include <nuttx/spinlock.h>
 #include <nuttx/net/ioctl.h>
 #include <nuttx/net/net.h>
 #include <nuttx/net/mii.h>
@@ -231,6 +232,10 @@ struct esp32_emac_s
   /* RX and TX buffer allocations */
 
   uint8_t alloc[EMAC_BUF_NUM * EMAC_BUF_LEN];
+
+  /* Device specific lock. */
+
+  spinlock_t lock;
 };
 
 /****************************************************************************
@@ -402,11 +407,11 @@ static inline uint8_t *emac_alloc_buffer(struct 
esp32_emac_s *priv)
 
   /* Allocate a buffer by returning the head of the free buffer list */
 
-  flags = enter_critical_section();
+  flags = spin_lock_irqsave(&priv->lock);
 
   p = (uint8_t *)sq_remfirst(&priv->freeb);
 
-  leave_critical_section(flags);
+  spin_unlock_irqrestore(&priv->lock, flags);
 
   return p;
 }

Reply via email to