From 83e95bdff4c48c661b50e1eec56d5fd293b28fbb Mon Sep 17 00:00:00 2001 From: Shell Date: Thu, 28 Mar 2024 23:42:56 +0800 Subject: sync smart & dfs (#8672) Signed-off-by: xqyjlj Signed-off-by: Shell Co-authored-by: xqyjlj --- components/drivers/ipc/completion.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'components/drivers/ipc/completion.c') diff --git a/components/drivers/ipc/completion.c b/components/drivers/ipc/completion.c index d74fcdc8d1..824f538129 100644 --- a/components/drivers/ipc/completion.c +++ b/components/drivers/ipc/completion.c @@ -134,7 +134,7 @@ RTM_EXPORT(rt_completion_wait); * * @param completion is a pointer to a completion object. */ -void rt_completion_done(struct rt_completion *completion) +static int _completion_done(struct rt_completion *completion) { rt_base_t level; rt_err_t error; @@ -145,7 +145,7 @@ void rt_completion_done(struct rt_completion *completion) if (RT_COMPLETION_FLAG(completion) == RT_COMPLETED) { rt_spin_unlock_irqrestore(&_completion_lock, level); - return; + return -RT_EBUSY; } suspend_thread = RT_COMPLETION_THREAD(completion); @@ -160,10 +160,38 @@ void rt_completion_done(struct rt_completion *completion) LOG_D("%s: failed to resume thread", __func__); } } + else + { + /* no thread waiting */ + error = -RT_EEMPTY; + } completion->susp_thread_n_flag = RT_COMPLETION_NEW_STAT(RT_NULL, RT_COMPLETED); rt_spin_unlock_irqrestore(&_completion_lock, level); + + return error; +} + +/** + * @brief This function indicates a completion has done. + * + * @param completion is a pointer to a completion object. + */ +void rt_completion_done(struct rt_completion *completion) +{ + _completion_done(completion); } RTM_EXPORT(rt_completion_done); +/** + * @brief This function indicates a completion has done and wakeup the thread + * + * @param completion is a pointer to a completion object. + */ +rt_err_t rt_completion_wakeup(struct rt_completion *completion) +{ + return _completion_done(completion); +} +RTM_EXPORT(rt_completion_wakeup); + -- cgit v1.3.1