kernel: fix error in synchronous work cancellation return value

The return value is documented to be true if the work was pending, but
the implementation returned true only if the work was actually running
(i.e. the caller had to wait).  It should also return true if
scheduled or submitted work was cancelled.

Note that this means the return value cannot be used to determine
whether the call slept.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
Peter Bigot 2021-04-16 11:48:50 -05:00 committed by Anas Nashif
commit 707dc22fb0
3 changed files with 28 additions and 16 deletions

View file

@ -3020,8 +3020,9 @@ int k_work_cancel(struct k_work *work);
* one completes. On architectures with CONFIG_KERNEL_COHERENCE the object
* must be allocated in coherent memory.
*
* @retval true if work was not idle (call had to wait for cancellation to
* complete);
* @retval true if work was pending (call had to wait for cancellation of a
* running handler to complete, or scheduled or submitted operations were
* cancelled);
* @retval false otherwise
*/
bool k_work_cancel_sync(struct k_work *work, struct k_work_sync *sync);
@ -3357,8 +3358,9 @@ int k_work_cancel_delayable(struct k_work_delayable *dwork);
* one completes. On architectures with CONFIG_KERNEL_COHERENCE the object
* must be allocated in coherent memory.
*
* @retval true if work was not idle (call had to wait for cancellation to
* complete);
* @retval true if work was not idle (call had to wait for cancellation of a
* running handler to complete, or scheduled or submitted operations were
* cancelled);
* @retval false otherwise
*/
bool k_work_cancel_delayable_sync(struct k_work_delayable *dwork,