From 4b0f42c24aad9c824fb98a3bb4c7cc2fd29b632a Mon Sep 17 00:00:00 2001 From: Shell Date: Tue, 9 Apr 2024 21:36:16 +0800 Subject: [drivers/serial] Introduce hooker for TTY (#8733) In this patch, a hook list has been introduced to address the concerns regarding coupling issues arising from modifications to the serial code for integrating TTY logic. Signed-off-by: Shell --- include/rtdef.h | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'include') diff --git a/include/rtdef.h b/include/rtdef.h index 085600433e..e3daa03828 100644 --- a/include/rtdef.h +++ b/include/rtdef.h @@ -525,23 +525,23 @@ struct rt_object_information * do_other_things(); * } */ -#define _RT_OBJECT_HOOKLIST_CALL(nodetype, nested, list, lock, argv) \ - do \ - { \ - nodetype iter; \ - rt_ubase_t level = rt_spin_lock_irqsave(&lock); \ - nested += 1; \ - rt_spin_unlock_irqrestore(&lock, level); \ - if (!rt_list_isempty(&list)) \ - { \ - rt_list_for_each_entry(iter, &list, list_node) \ - { \ - iter->handler argv; \ - } \ - } \ - level = rt_spin_lock_irqsave(&lock); \ - nested -= 1; \ - rt_spin_unlock_irqrestore(&lock, level); \ +#define _RT_OBJECT_HOOKLIST_CALL(nodetype, nested, list, lock, argv) \ + do \ + { \ + nodetype iter, next; \ + rt_ubase_t level = rt_spin_lock_irqsave(&lock); \ + nested += 1; \ + rt_spin_unlock_irqrestore(&lock, level); \ + if (!rt_list_isempty(&list)) \ + { \ + rt_list_for_each_entry_safe(iter, next, &list, list_node) \ + { \ + iter->handler argv; \ + } \ + } \ + level = rt_spin_lock_irqsave(&lock); \ + nested -= 1; \ + rt_spin_unlock_irqrestore(&lock, level); \ } while (0) #define RT_OBJECT_HOOKLIST_CALL(name, argv) \ _RT_OBJECT_HOOKLIST_CALL(name##_hooklistnode_t, name##_nested, \ -- cgit v1.3.1