diff options
author | Masahiro Yamada <masahiroy@kernel.org> | 2024-10-23 21:18:01 +0300 |
---|---|---|
committer | Masahiro Yamada <masahiroy@kernel.org> | 2024-11-06 02:46:34 +0300 |
commit | bce590f1020742d81e9fbfe3b045538973111c11 (patch) | |
tree | 23dcf54e53b2b41b78406f6639205ef8bb4ab959 /scripts/kconfig | |
parent | 929ce506d60ede917f241fb40e0bed6ab3e52999 (diff) | |
download | linux-bce590f1020742d81e9fbfe3b045538973111c11.tar.xz |
kconfig: add sym_get_prompt_menu() helper function
Split out the code that retrieves the menu entry with a prompt, so it
can be reused in other functions.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Diffstat (limited to 'scripts/kconfig')
-rw-r--r-- | scripts/kconfig/lkc_proto.h | 1 | ||||
-rw-r--r-- | scripts/kconfig/symbol.c | 26 |
2 files changed, 20 insertions, 7 deletions
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index 63519cd24bc7..8914b4e8f2a8 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h @@ -34,6 +34,7 @@ bool sym_string_valid(struct symbol *sym, const char *newval); bool sym_string_within_range(struct symbol *sym, const char *str); bool sym_set_string_value(struct symbol *sym, const char *newval); bool sym_is_changeable(const struct symbol *sym); +struct menu *sym_get_prompt_menu(const struct symbol *sym); struct menu *sym_get_choice_menu(const struct symbol *sym); const char * sym_get_string_value(struct symbol *sym); diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index a3af93aaaf32..89b84bf8e21f 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -71,6 +71,24 @@ const char *sym_type_name(enum symbol_type type) } /** + * sym_get_prompt_menu - get the menu entry with a prompt + * + * @sym: a symbol pointer + * + * Return: the menu entry with a prompt. + */ +struct menu *sym_get_prompt_menu(const struct symbol *sym) +{ + struct menu *m; + + list_for_each_entry(m, &sym->menus, link) + if (m->prompt) + return m; + + return NULL; +} + +/** * sym_get_choice_menu - get the parent choice menu if present * * @sym: a symbol pointer @@ -80,18 +98,12 @@ const char *sym_type_name(enum symbol_type type) struct menu *sym_get_choice_menu(const struct symbol *sym) { struct menu *menu = NULL; - struct menu *m; /* * Choice members must have a prompt. Find a menu entry with a prompt, * and assume it resides inside a choice block. */ - list_for_each_entry(m, &sym->menus, link) - if (m->prompt) { - menu = m; - break; - } - + menu = sym_get_prompt_menu(sym); if (!menu) return NULL; |