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 <dmitriy.korovkin@windriver.com>
This commit is contained in:
Dmitriy Korovkin 2016-01-25 14:41:19 -05:00 committed by Anas Nashif
commit 9183e1f4de

View file

@ -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 */