From 606d72f64bb7a2b77e428032dde93d44c2d42a26 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Sat, 23 Nov 2019 11:57:11 +0100 Subject: [PATCH] cpu/atmega_common: Clean up & fix IRQ handling At the end of an ISR, the ATmega code was doing an `thread_yield()` instead of a `thread_yield_higher()`. This resulted in tests/isr_yield_higher failing. Fixing this saves a few lines of code, some ROM, and solves the issue. --- cpu/atmega_common/include/cpu.h | 17 +---------------- cpu/atmega_common/thread_arch.c | 3 ++- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/cpu/atmega_common/include/cpu.h b/cpu/atmega_common/include/cpu.h index d0db41e42c..c7321287ce 100644 --- a/cpu/atmega_common/include/cpu.h +++ b/cpu/atmega_common/include/cpu.h @@ -71,25 +71,10 @@ static inline void atmega_enter_isr(void) atmega_in_isr = 1; } -/** - * @brief Exit ISR mode and yield with a return from interrupt. Use at the - * end of ISRs in place of thread_yield_higher. If thread_yield is needed, use - * thread_yield followed by thread_yield_isr instead of thread_yield alone. - */ -void atmega_thread_yield_isr(void) - /** * @brief Run this code on exiting interrupt routines */ -static inline void atmega_exit_isr(void) -{ - if (sched_context_switch_request) { - thread_yield(); - atmega_in_isr = 0; - atmega_thread_yield_isr() - } - atmega_in_isr = 0; -} +void atmega_exit_isr(void); /** * @brief Initialization of the CPU diff --git a/cpu/atmega_common/thread_arch.c b/cpu/atmega_common/thread_arch.c index 263791f273..6edbf4c942 100644 --- a/cpu/atmega_common/thread_arch.c +++ b/cpu/atmega_common/thread_arch.c @@ -245,8 +245,9 @@ void thread_yield_higher(void) } } -void atmega_thread_yield_isr(void) +void atmega_exit_isr(void) { + atmega_in_isr = 0; atmega_context_save(); sched_run(); atmega_context_restore();