From 9183e1f4de334825d89e6af16b351bffb60037ab Mon Sep 17 00:00:00 2001 From: Dmitriy Korovkin Date: Mon, 25 Jan 2016 14:41:19 -0500 Subject: [PATCH] device: Make device_sync_call_complete aware of the caller context device_sync_call_complete can be called from ISR, fiber or task, thus needs to be aware not only of the waiter context, but also on the actual caller one. Change-Id: I76652a2c44d854db9c34e7192355d455d43f61e3 Signed-off-by: Dmitriy Korovkin --- include/device.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/include/device.h b/include/device.h index 57be9b05d52..e6413dea5f2 100644 --- a/include/device.h +++ b/include/device.h @@ -231,10 +231,15 @@ static inline void device_sync_call_wait(device_sync_call_t *sync) */ static inline void device_sync_call_complete(device_sync_call_t *sync) { + static void (*func[3])(ksem_t sema) = { + isr_sem_give, + fiber_sem_give, + task_sem_give + }; if (sync->waiter_is_task) { - task_sem_give(sync->t_sem); + func[sys_execution_context_type_get()](sync->t_sem); } else { - nano_isr_sem_give(&sync->f_sem); + nano_sem_give(&sync->f_sem); } } @@ -259,7 +264,7 @@ static inline void device_sync_call_wait(device_sync_call_t *sync) */ static inline void device_sync_call_complete(device_sync_call_t *sync) { - nano_isr_sem_give(&sync->f_sem); + nano_sem_give(&sync->f_sem); } #endif /* CONFIG_MICROKERNEL || CONFIG_NANOKERNEL */