kconfig: add menu_next() function and menu_for_each(_sub)_entry macros
authorMasahiro Yamada <masahiroy@kernel.org>
Sun, 21 Apr 2024 09:02:51 +0000 (18:02 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Thu, 2 May 2024 10:48:26 +0000 (19:48 +0900)
commit7284b4fbc8473965f9c053f3fa8b194af8ed4738
tree14827e7f55a227ba728556bb6069bd8465f1d19c
parent377d9095117c084b835e38c020faf5a78e386f01
kconfig: add menu_next() function and menu_for_each(_sub)_entry macros

Several functions require traversing menu entries sequentially. This
commit introduces some helpers to simplify such operations.

The menu_next() function facilitates depth-first traversal:

 1. Descend to the child level if the current menu has one
 2. Move to the next sibling at the same level if available
 3. Ascend to the parent level if there is no more child or sibling

The menu_for_each_sub_entry() macro iterates over all submenu entries
using depth-first traverse.

The menu_for_each_entry() macro is the same, but over all menu entries.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
scripts/kconfig/lkc.h
scripts/kconfig/menu.c