You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2022/11/14 00:34:14 UTC

[incubator-nuttx] 03/10: arch: Remove xxx_sem[take|give] and call nxmuex_[lock|unlock] directly

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

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

commit a8a25cb09f8ba3796e7d4f8ecf200b1703c22441
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Wed Nov 2 17:05:28 2022 +0800

    arch: Remove xxx_sem[take|give] and call nxmuex_[lock|unlock] directly
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 arch/arm/src/imxrt/imxrt_edma.c       | 24 ++----------------------
 arch/arm/src/kinetis/kinetis_edma.c   | 24 ++----------------------
 arch/arm/src/s32k1xx/s32k1xx_edma.c   | 24 ++----------------------
 arch/arm/src/s32k3xx/s32k3xx_edma.c   | 24 ++----------------------
 arch/arm/src/sama5/sam_dmac.c         | 24 +++---------------------
 arch/arm/src/sama5/sam_xdmac.c        | 24 +++---------------------
 arch/arm/src/samd2l2/sam_dmac.c       | 28 ++--------------------------
 arch/arm/src/samd5e5/sam_dmac.c       | 28 ++--------------------------
 arch/arm/src/samv7/sam_xdmac.c        | 24 +++---------------------
 arch/arm/src/stm32l4/stm32l4_i2c.c    |  6 +++++-
 arch/xtensa/src/esp32/esp32_i2s.c     | 29 ++---------------------------
 arch/xtensa/src/esp32s2/esp32s2_i2s.c | 29 ++---------------------------
 12 files changed, 30 insertions(+), 258 deletions(-)

diff --git a/arch/arm/src/imxrt/imxrt_edma.c b/arch/arm/src/imxrt/imxrt_edma.c
index b5c58278ff..a1ced125a0 100644
--- a/arch/arm/src/imxrt/imxrt_edma.c
+++ b/arch/arm/src/imxrt/imxrt_edma.c
@@ -178,26 +178,6 @@ static struct imxrt_edmatcd_s g_tcd_pool[CONFIG_IMXRT_EDMA_NTCD]
  * Private Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: imxrt_takedsem() and imxrt_givedsem()
- *
- * Description:
- *   Used to wait for availability of descriptors in the descriptor table.
- *
- ****************************************************************************/
-
-#if CONFIG_IMXRT_EDMA_NTCD > 0
-static void imxrt_takedsem(void)
-{
-  nxsem_wait_uninterruptible(&g_edma.dsem);
-}
-
-static inline void imxrt_givedsem(void)
-{
-  nxsem_post(&g_edma.dsem);
-}
-#endif
-
 /****************************************************************************
  * Name: imxrt_tcd_alloc
  *
@@ -221,7 +201,7 @@ static struct imxrt_edmatcd_s *imxrt_tcd_alloc(void)
    */
 
   flags = enter_critical_section();
-  imxrt_takedsem();
+  nxsem_wait_uninterruptible(&g_edma.dsem);
 
   /* Now there should be a TCD in the free list reserved just for us */
 
@@ -253,7 +233,7 @@ static void imxrt_tcd_free(struct imxrt_edmatcd_s *tcd)
 
   flags = spin_lock_irqsave(NULL);
   sq_addlast((sq_entry_t *)tcd, &g_tcd_free);
-  imxrt_givedsem();
+  nxsem_post(&g_edma.dsem);
   spin_unlock_irqrestore(NULL, flags);
 }
 #endif
diff --git a/arch/arm/src/kinetis/kinetis_edma.c b/arch/arm/src/kinetis/kinetis_edma.c
index 6120e94d60..c2da8d2e45 100644
--- a/arch/arm/src/kinetis/kinetis_edma.c
+++ b/arch/arm/src/kinetis/kinetis_edma.c
@@ -180,26 +180,6 @@ static struct kinetis_edmatcd_s g_tcd_pool[CONFIG_KINETIS_EDMA_NTCD]
  * Private Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: kinetis_takedsem() and kinetis_givedsem()
- *
- * Description:
- *   Used to wait for availability of descriptors in the descriptor table.
- *
- ****************************************************************************/
-
-#if CONFIG_KINETIS_EDMA_NTCD > 0
-static void kinetis_takedsem(void)
-{
-  nxsem_wait_uninterruptible(&g_edma.dsem);
-}
-
-static inline void kinetis_givedsem(void)
-{
-  nxsem_post(&g_edma.dsem);
-}
-#endif
-
 /****************************************************************************
  * Name: kinetis_tcd_alloc
  *
@@ -223,7 +203,7 @@ static struct kinetis_edmatcd_s *kinetis_tcd_alloc(void)
    */
 
   flags = enter_critical_section();
-  kinetis_takedsem();
+  nxsem_wait_uninterruptible(&g_edma.dsem);
 
   /* Now there should be a TCD in the free list reserved just for us */
 
@@ -255,7 +235,7 @@ static void kinetis_tcd_free(struct kinetis_edmatcd_s *tcd)
 
   flags = spin_lock_irqsave(NULL);
   sq_addlast((sq_entry_t *)tcd, &g_tcd_free);
-  kinetis_givedsem();
+  nxsem_post(&g_edma.dsem);
   spin_unlock_irqrestore(NULL, flags);
 }
 #endif
diff --git a/arch/arm/src/s32k1xx/s32k1xx_edma.c b/arch/arm/src/s32k1xx/s32k1xx_edma.c
index 27c0a22ccf..8e3077bdc3 100644
--- a/arch/arm/src/s32k1xx/s32k1xx_edma.c
+++ b/arch/arm/src/s32k1xx/s32k1xx_edma.c
@@ -178,26 +178,6 @@ static struct s32k1xx_edmatcd_s g_tcd_pool[CONFIG_S32K1XX_EDMA_NTCD]
  * Private Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: s32k1xx_takedsem() and s32k1xx_givedsem()
- *
- * Description:
- *   Used to wait for availability of descriptors in the descriptor table.
- *
- ****************************************************************************/
-
-#if CONFIG_S32K1XX_EDMA_NTCD > 0
-static void s32k1xx_takedsem(void)
-{
-  nxsem_wait_uninterruptible(&g_edma.dsem);
-}
-
-static inline void s32k1xx_givedsem(void)
-{
-  nxsem_post(&g_edma.dsem);
-}
-#endif
-
 /****************************************************************************
  * Name: s32k1xx_tcd_alloc
  *
@@ -221,7 +201,7 @@ static struct s32k1xx_edmatcd_s *s32k1xx_tcd_alloc(void)
    */
 
   flags = enter_critical_section();
-  s32k1xx_takedsem();
+  nxsem_wait_uninterruptible(&g_edma.dsem);
 
   /* Now there should be a TCD in the free list reserved just for us */
 
@@ -253,7 +233,7 @@ static void s32k1xx_tcd_free(struct s32k1xx_edmatcd_s *tcd)
 
   flags = spin_lock_irqsave(NULL);
   sq_addlast((sq_entry_t *)tcd, &g_tcd_free);
-  s32k1xx_givedsem();
+  nxsem_post(&g_edma.dsem);
   spin_unlock_irqrestore(NULL, flags);
 }
 #endif
diff --git a/arch/arm/src/s32k3xx/s32k3xx_edma.c b/arch/arm/src/s32k3xx/s32k3xx_edma.c
index 9d0b9908bd..a28af16895 100644
--- a/arch/arm/src/s32k3xx/s32k3xx_edma.c
+++ b/arch/arm/src/s32k3xx/s32k3xx_edma.c
@@ -422,26 +422,6 @@ const struct peripheral_clock_config_s edma_clockconfig[] =
  * Private Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: s32k3xx_takedsem() and s32k3xx_givedsem()
- *
- * Description:
- *   Used to wait for availability of descriptors in the descriptor table.
- *
- ****************************************************************************/
-
-#if CONFIG_S32K3XX_EDMA_NTCD > 0
-static void s32k3xx_takedsem(void)
-{
-  nxsem_wait_uninterruptible(&g_edma.dsem);
-}
-
-static inline void s32k3xx_givedsem(void)
-{
-  nxsem_post(&g_edma.dsem);
-}
-#endif
-
 /****************************************************************************
  * Name: s32k3xx_tcd_alloc
  *
@@ -465,7 +445,7 @@ static struct s32k3xx_edmatcd_s *s32k3xx_tcd_alloc(void)
    */
 
   flags = enter_critical_section();
-  s32k3xx_takedsem();
+  nxsem_wait_uninterruptible(&g_edma.dsem);
 
   /* Now there should be a TCD in the free list reserved just for us */
 
@@ -497,7 +477,7 @@ static void s32k3xx_tcd_free(struct s32k3xx_edmatcd_s *tcd)
 
   flags = spin_lock_irqsave(NULL);
   sq_addlast((sq_entry_t *)tcd, &g_tcd_free);
-  s32k3xx_givedsem();
+  nxsem_post(&g_edma.dsem);
   spin_unlock_irqrestore(NULL, flags);
 }
 #endif
diff --git a/arch/arm/src/sama5/sam_dmac.c b/arch/arm/src/sama5/sam_dmac.c
index b70a09fa4c..58177b54ac 100644
--- a/arch/arm/src/sama5/sam_dmac.c
+++ b/arch/arm/src/sama5/sam_dmac.c
@@ -469,24 +469,6 @@ static struct sam_dmac_s g_dmac1 =
  * Private Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: sam_takedsem() and sam_givedsem()
- *
- * Description:
- *   Used to wait for availability of descriptors in the descriptor table.
- *
- ****************************************************************************/
-
-static int sam_takedsem(struct sam_dmac_s *dmac)
-{
-  return nxsem_wait_uninterruptible(&dmac->dsem);
-}
-
-static inline void sam_givedsem(struct sam_dmac_s *dmac)
-{
-  nxsem_post(&dmac->dsem);
-}
-
 /****************************************************************************
  * Name: sam_getdmac
  *
@@ -1340,7 +1322,7 @@ sam_allocdesc(struct sam_dmach_s *dmach, struct dma_linklist_s *prev,
        * there is at least one free descriptor in the table and it is ours.
        */
 
-      ret = sam_takedsem(dmac);
+      ret = nxsem_wait_uninterruptible(&dmac->dsem);
       if (ret < 0)
         {
           return NULL;
@@ -1355,7 +1337,7 @@ sam_allocdesc(struct sam_dmach_s *dmach, struct dma_linklist_s *prev,
       ret = nxmutex_lock(&dmac->chlock);
       if (ret < 0)
         {
-          sam_givedsem(dmac);
+          nxsem_post(&dmac->dsem);
           return NULL;
         }
 
@@ -1477,7 +1459,7 @@ static void sam_freelinklist(struct sam_dmach_s *dmach)
        */
 
       memset(desc, 0, sizeof(struct dma_linklist_s));
-      sam_givedsem(dmac);
+      nxsem_post(&dmac->dsem);
 
       /* Get the virtual address of the next descriptor in the list */
 
diff --git a/arch/arm/src/sama5/sam_xdmac.c b/arch/arm/src/sama5/sam_xdmac.c
index 0074f11279..a97d249b60 100644
--- a/arch/arm/src/sama5/sam_xdmac.c
+++ b/arch/arm/src/sama5/sam_xdmac.c
@@ -738,24 +738,6 @@ static struct sam_xdmac_s g_xdmac1 =
  * Private Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: sam_takedsem() and sam_givedsem()
- *
- * Description:
- *   Used to wait for availability of descriptors in the descriptor table.
- *
- ****************************************************************************/
-
-static int sam_takedsem(struct sam_xdmac_s *xdmac)
-{
-  return nxsem_wait_uninterruptible(&xdmac->dsem);
-}
-
-static inline void sam_givedsem(struct sam_xdmac_s *xdmac)
-{
-  nxsem_post(&xdmac->dsem);
-}
-
 /****************************************************************************
  * Name: sam_getdmac
  *
@@ -1398,7 +1380,7 @@ sam_allocdesc(struct sam_xdmach_s *xdmach, struct chnext_view1_s *prev,
        * there is at least one free descriptor in the table and it is ours.
        */
 
-      ret = sam_takedsem(xdmac);
+      ret = nxsem_wait_uninterruptible(&xdmac->dsem);
       if (ret < 0)
         {
           return NULL;
@@ -1413,7 +1395,7 @@ sam_allocdesc(struct sam_xdmach_s *xdmach, struct chnext_view1_s *prev,
       ret = nxmutex_lock(&xdmac->chlock);
       if (ret < 0)
         {
-          sam_givedsem(xdmac);
+          nxsem_post(&xdmac->dsem);
           return NULL;
         }
 
@@ -1528,7 +1510,7 @@ static void sam_freelinklist(struct sam_xdmach_s *xdmach)
        */
 
       memset(descr, 0, sizeof(struct chnext_view1_s));
-      sam_givedsem(xdmac);
+      nxsem_post(&xdmac->dsem);
 
       /* Get the virtual address of the next descriptor in the list */
 
diff --git a/arch/arm/src/samd2l2/sam_dmac.c b/arch/arm/src/samd2l2/sam_dmac.c
index 3a5808eb08..1e41f6dff0 100644
--- a/arch/arm/src/samd2l2/sam_dmac.c
+++ b/arch/arm/src/samd2l2/sam_dmac.c
@@ -99,10 +99,6 @@ struct sam_dmach_s
  * Private Function Prototypes
  ****************************************************************************/
 
-#if CONFIG_SAMD2L2_DMAC_NDESC > 0
-static void   sam_takedsem(void);
-static inline void sam_givedsem(void);
-#endif
 static void   sam_dmaterminate(struct sam_dmach_s *dmach, int result);
 static int    sam_dmainterrupt(int irq, void *context, void *arg);
 static struct dma_desc_s *sam_alloc_desc(struct sam_dmach_s *dmach);
@@ -158,26 +154,6 @@ static struct dma_desc_s g_dma_desc[CONFIG_SAMD2L2_DMAC_NDESC]
  * Private Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: sam_takedsem() and sam_givedsem()
- *
- * Description:
- *   Used to wait for availability of descriptors in the descriptor table.
- *
- ****************************************************************************/
-
-#if CONFIG_SAMD2L2_DMAC_NDESC > 0
-static void sam_takedsem(void)
-{
-  nxsem_wait_uninterruptible(&g_dsem);
-}
-
-static inline void sam_givedsem(void)
-{
-  nxsem_post(&g_dsem);
-}
-#endif
-
 /****************************************************************************
  * Name: sam_dmaterminate
  *
@@ -356,7 +332,7 @@ static struct dma_desc_s *sam_alloc_desc(struct sam_dmach_s *dmach)
        * it is ours.
        */
 
-      sam_takedsem();
+      nxsem_wait_uninterruptible(&g_dsem);
 
       /* Examine each list entry to find an available one -- i.e., one
        * with srcaddr == 0.  That srcaddr field is set to zero by the DMA
@@ -512,7 +488,7 @@ static void sam_free_desc(struct sam_dmach_s *dmach)
 
       next = (struct dma_desc_s *)desc->descaddr;
       memset(desc, 0, sizeof(struct dma_desc_s));
-      sam_givedsem();
+      nxsem_post(&g_dsem);
     }
 #endif
 }
diff --git a/arch/arm/src/samd5e5/sam_dmac.c b/arch/arm/src/samd5e5/sam_dmac.c
index 10433fa71c..bec956902c 100644
--- a/arch/arm/src/samd5e5/sam_dmac.c
+++ b/arch/arm/src/samd5e5/sam_dmac.c
@@ -100,10 +100,6 @@ struct sam_dmach_s
  * Private Function Prototypes
  ****************************************************************************/
 
-#if CONFIG_SAMD5E5_DMAC_NDESC > 0
-static void   sam_takedsem(void);
-static inline void sam_givedsem(void);
-#endif
 static void   sam_dmaterminate(struct sam_dmach_s *dmach, int result);
 static int    sam_dmainterrupt(int irq, void *context, void *arg);
 static struct dma_desc_s *sam_alloc_desc(struct sam_dmach_s *dmach);
@@ -157,26 +153,6 @@ static struct dma_desc_s g_dma_desc[CONFIG_SAMD5E5_DMAC_NDESC]
  * Private Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: sam_takedsem() and sam_givedsem()
- *
- * Description:
- *   Used to wait for availability of descriptors in the descriptor table.
- *
- ****************************************************************************/
-
-#if CONFIG_SAMD5E5_DMAC_NDESC > 0
-static void sam_takedsem(void)
-{
-  nxsem_wait_uninterruptible(&g_dsem);
-}
-
-static inline void sam_givedsem(void)
-{
-  nxsem_post(&g_dsem);
-}
-#endif
-
 /****************************************************************************
  * Name: sam_dmaterminate
  *
@@ -328,7 +304,7 @@ static struct dma_desc_s *sam_alloc_desc(struct sam_dmach_s *dmach)
        * it is ours.
        */
 
-      sam_takedsem();
+      nxsem_wait_uninterruptible(&g_dsem);
 
       /* Examine each list entry to find an available one -- i.e., one
        * with srcaddr == 0.  That srcaddr field is set to zero by the DMA
@@ -484,7 +460,7 @@ static void sam_free_desc(struct sam_dmach_s *dmach)
 
       next = (struct dma_desc_s *)desc->descaddr;
       memset(desc, 0, sizeof(struct dma_desc_s));
-      sam_givedsem();
+      nxsem_post(&g_dsem);
     }
 #endif
 }
diff --git a/arch/arm/src/samv7/sam_xdmac.c b/arch/arm/src/samv7/sam_xdmac.c
index a7c1d2a9d9..21b8b00704 100644
--- a/arch/arm/src/samv7/sam_xdmac.c
+++ b/arch/arm/src/samv7/sam_xdmac.c
@@ -353,24 +353,6 @@ static struct sam_xdmac_s g_xdmac =
  * Private Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: sam_takedsem() and sam_givedsem()
- *
- * Description:
- *   Used to wait for availability of descriptors in the descriptor table.
- *
- ****************************************************************************/
-
-static int sam_takedsem(struct sam_xdmac_s *xdmac)
-{
-  return nxsem_wait_uninterruptible(&xdmac->dsem);
-}
-
-static inline void sam_givedsem(struct sam_xdmac_s *xdmac)
-{
-  nxsem_post(&xdmac->dsem);
-}
-
 /****************************************************************************
  * Name: sam_getdmac
  *
@@ -979,7 +961,7 @@ sam_allocdesc(struct sam_xdmach_s *xdmach, struct chnext_view1_s *prev,
        * there is at least one free descriptor in the table and it is ours.
        */
 
-      ret = sam_takedsem(xdmac);
+      ret = nxsem_wait_uninterruptible(&xdmac->dsem);
       if (ret < 0)
         {
           return NULL;
@@ -994,7 +976,7 @@ sam_allocdesc(struct sam_xdmach_s *xdmach, struct chnext_view1_s *prev,
       ret = nxmutex_lock(&xdmac->chlock);
       if (ret < 0)
         {
-          sam_givedsem(xdmac);
+          nxsem_post(&xdmac->dsem);
           return NULL;
         }
 
@@ -1109,7 +1091,7 @@ static void sam_freelinklist(struct sam_xdmach_s *xdmach)
        */
 
       memset(descr, 0, sizeof(struct chnext_view1_s));
-      sam_givedsem(xdmac);
+      nxsem_post(&xdmac->dsem);
 
       /* Get the virtual address of the next descriptor in the list */
 
diff --git a/arch/arm/src/stm32l4/stm32l4_i2c.c b/arch/arm/src/stm32l4/stm32l4_i2c.c
index ad188df8b0..7a2ed68dc0 100644
--- a/arch/arm/src/stm32l4/stm32l4_i2c.c
+++ b/arch/arm/src/stm32l4/stm32l4_i2c.c
@@ -2682,11 +2682,15 @@ static int stm32l4_i2c_transfer(struct i2c_master_s *dev,
                                 struct i2c_msg_s *msgs,
                                 int count)
 {
+  struct stm32l4_i2c_priv_s *priv;
   int ret;
 
+  DEBUGASSERT(dev);
+  priv = ((struct stm32l4_i2c_inst_s *)dev)->priv;
+
   /* Ensure that address or flags don't change meanwhile */
 
-  ret = nxmutex_lock(&((struct stm32l4_i2c_inst_s *)dev)->priv->lock);
+  ret = nxmutex_lock(&priv->lock);
   if (ret >= 0)
     {
       ret = stm32l4_i2c_process(dev, msgs, count);
diff --git a/arch/xtensa/src/esp32/esp32_i2s.c b/arch/xtensa/src/esp32/esp32_i2s.c
index 3c6ed2c495..0fcfb0b16d 100644
--- a/arch/xtensa/src/esp32/esp32_i2s.c
+++ b/arch/xtensa/src/esp32/esp32_i2s.c
@@ -304,11 +304,6 @@ struct esp32_i2s_s
 #  define       i2s_dump_buffer(m,b,s)
 #endif
 
-/* Semaphore helpers */
-
-static int      i2s_bufsem_take(struct esp32_i2s_s *priv);
-#define         i2s_bufsem_give(priv) nxsem_post(&priv->bufsem)
-
 /* Buffer container helpers */
 
 static struct esp32_buffer_s *
@@ -484,26 +479,6 @@ static struct esp32_i2s_s esp32_i2s1_priv =
  * Private Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: i2s_bufsem_take
- *
- * Description:
- *   Take the buffer semaphore handling any exceptional conditions
- *
- * Input Parameters:
- *   priv - A reference to the i2s peripheral state
- *
- * Returned Value:
- *   Normally OK, but may return -ECANCELED in the rare event that the task
- *   has been canceled.
- *
- ****************************************************************************/
-
-static int i2s_bufsem_take(struct esp32_i2s_s *priv)
-{
-  return nxsem_wait_uninterruptible(&priv->bufsem);
-}
-
 /****************************************************************************
  * Name: i2s_buf_allocate
  *
@@ -534,7 +509,7 @@ static struct esp32_buffer_s *i2s_buf_allocate(struct esp32_i2s_s *priv)
    * have at least one free buffer container.
    */
 
-  ret = i2s_bufsem_take(priv);
+  ret = nxsem_wait_uninterruptible(&priv->bufsem);
   if (ret < 0)
     {
       return NULL;
@@ -590,7 +565,7 @@ static void i2s_buf_free(struct esp32_i2s_s *priv,
 
   /* Wake up any threads waiting for a buffer container */
 
-  i2s_bufsem_give(priv);
+  nxsem_post(&priv->bufsem);
 }
 
 /****************************************************************************
diff --git a/arch/xtensa/src/esp32s2/esp32s2_i2s.c b/arch/xtensa/src/esp32s2/esp32s2_i2s.c
index 6e67403e98..47f969626d 100644
--- a/arch/xtensa/src/esp32s2/esp32s2_i2s.c
+++ b/arch/xtensa/src/esp32s2/esp32s2_i2s.c
@@ -286,11 +286,6 @@ struct esp32s2_i2s_s
 #  define       i2s_dump_buffer(m,b,s)
 #endif
 
-/* Semaphore helpers */
-
-static int      i2s_bufsem_take(struct esp32s2_i2s_s *priv);
-#define         i2s_bufsem_give(priv) nxsem_post(&priv->bufsem)
-
 /* Buffer container helpers */
 
 static struct esp32s2_buffer_s *
@@ -406,26 +401,6 @@ static struct esp32s2_i2s_s esp32s2_i2s0_priv =
  * Private Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: i2s_bufsem_take
- *
- * Description:
- *   Take the buffer semaphore handling any exceptional conditions
- *
- * Input Parameters:
- *   priv - A reference to the i2s peripheral state
- *
- * Returned Value:
- *   Normally OK, but may return -ECANCELED in the rare event that the task
- *   has been canceled.
- *
- ****************************************************************************/
-
-static int i2s_bufsem_take(struct esp32s2_i2s_s *priv)
-{
-  return nxsem_wait_uninterruptible(&priv->bufsem);
-}
-
 /****************************************************************************
  * Name: i2s_buf_allocate
  *
@@ -456,7 +431,7 @@ static struct esp32s2_buffer_s *i2s_buf_allocate(struct esp32s2_i2s_s *priv)
    * have at least one free buffer container.
    */
 
-  ret = i2s_bufsem_take(priv);
+  ret = nxsem_wait_uninterruptible(&priv->bufsem);
   if (ret < 0)
     {
       return NULL;
@@ -512,7 +487,7 @@ static void i2s_buf_free(struct esp32s2_i2s_s *priv,
 
   /* Wake up any threads waiting for a buffer container */
 
-  i2s_bufsem_give(priv);
+  nxsem_post(&priv->bufsem);
 }
 
 /****************************************************************************