You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/10/16 07:01:42 UTC
[incubator-nuttx] 09/16: esp32_emac.c: Use device specific locks.
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 <ab...@espressif.com>
AuthorDate: Thu Sep 9 13:02:04 2021 +0200
esp32_emac.c: Use device specific locks.
Signed-off-by: Abdelatif Guettouche <ab...@espressif.com>
---
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;
}