[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 <smokewood@qq.com>
This commit is contained in:
Shell
2024-04-09 21:36:16 +08:00
committed by GitHub
parent 38204386b3
commit 4b0f42c24a
11 changed files with 90 additions and 35 deletions

View File

@@ -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, \