arch: Replace sem_t with mutex_t for the lock case

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

temp

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-11-02 14:42:10 +08:00 committed by Masayuki Ishikawa
parent a8a25cb09f
commit 14c3bc3b8c

View File

@ -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;
}