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:15 UTC

[incubator-nuttx] 04/10: arch: Replace sem_t with mutex_t for the lock case

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 14c3bc3b8c43b068a9d32fdea42433c0b7e63e2b
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Wed Nov 2 14:42:10 2022 +0800

    arch: Replace sem_t with mutex_t for the lock case
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
    
    temp
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 arch/risc-v/src/bl602/bl602_dma.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/risc-v/src/bl602/bl602_dma.c b/arch/risc-v/src/bl602/bl602_dma.c
index b153b9b5e5..fa41c6ac5c 100644
--- a/arch/risc-v/src/bl602/bl602_dma.c
+++ b/arch/risc-v/src/bl602/bl602_dma.c
@@ -57,8 +57,8 @@ struct dma_channel_s
 
 struct dma_controller_s
 {
-  sem_t exclsem; /* Protects channel table */
-  sem_t chansem; /* Count of free channels */
+  mutex_t chanlock; /* Protects channel table */
+  sem_t chansem;    /* Count of free channels */
 };
 
 /****************************************************************************
@@ -69,7 +69,7 @@ struct dma_controller_s
 
 static struct dma_controller_s g_dmac =
 {
-  .exclsem = NXSEM_INITIALIZER(1, PRIOINHERIT_FLAGS_ENABLE),
+  .chanlock = NXMUTEX_INITIALIZER,
   .chansem = SEM_INITIALIZER(BL602_DMA_NCHANNELS),
 };
 
@@ -176,7 +176,7 @@ int8_t bl602_dma_channel_request(bl602_dma_callback_t callback, void *arg)
 
   /* Get exclusive access to the DMA channel list */
 
-  ret = nxsem_wait_uninterruptible(&g_dmac.exclsem);
+  ret = nxmutex_lock(&g_dmac.chanlock);
   if (ret < 0)
     {
       nxsem_post(&g_dmac.chansem);
@@ -198,7 +198,7 @@ int8_t bl602_dma_channel_request(bl602_dma_callback_t callback, void *arg)
         }
     }
 
-  nxsem_post(&g_dmac.exclsem);
+  nxmutex_unlock(&g_dmac.chanlock);
 
   /* Since we have reserved a DMA descriptor by taking a count from chansem,
    * it would be a serious logic failure if we could not find a free channel
@@ -229,7 +229,7 @@ int bl602_dma_channel_release(uint8_t channel_id)
 {
   /* Get exclusive access to the DMA channel list */
 
-  if (nxsem_wait_uninterruptible(&g_dmac.exclsem) < 0)
+  if (nxmutex_lock(&g_dmac.chanlock) < 0)
     {
       return -1;
     }
@@ -246,7 +246,7 @@ int bl602_dma_channel_release(uint8_t channel_id)
       nxsem_post(&g_dmac.chansem);
     }
 
-  nxsem_post(&g_dmac.exclsem);
+  nxmutex_unlock(&g_dmac.chanlock);
   return 0;
 }