diff options
| author | Shell <[email protected]> | 2024-03-28 23:42:56 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-03-28 23:42:56 +0800 |
| commit | 83e95bdff4c48c661b50e1eec56d5fd293b28fbb (patch) | |
| tree | 9e0c2065950f0804e5009da71c8e0f590224cade /components/drivers/ipc/completion.c | |
| parent | 40e26f4909fa61ada775ba86b44d8300aaf5d250 (diff) | |
sync smart & dfs (#8672)
Signed-off-by: xqyjlj <[email protected]>
Signed-off-by: Shell <[email protected]>
Co-authored-by: xqyjlj <[email protected]>
Diffstat (limited to 'components/drivers/ipc/completion.c')
| -rw-r--r-- | components/drivers/ipc/completion.c | 32 |
1 files changed, 30 insertions, 2 deletions
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); + |
