1
0
Fork 0
mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-01-22 16:06:04 -05:00

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>
This commit is contained in:
Masahiro Yamada 2024-10-24 03:18:01 +09:00
parent 929ce506d6
commit bce590f102
2 changed files with 20 additions and 7 deletions

View file

@ -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_string_within_range(struct symbol *sym, const char *str);
bool sym_set_string_value(struct symbol *sym, const char *newval); bool sym_set_string_value(struct symbol *sym, const char *newval);
bool sym_is_changeable(const struct symbol *sym); 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); struct menu *sym_get_choice_menu(const struct symbol *sym);
const char * sym_get_string_value(struct symbol *sym); const char * sym_get_string_value(struct symbol *sym);

View file

@ -70,6 +70,24 @@ const char *sym_type_name(enum symbol_type type)
return "???"; return "???";
} }
/**
* 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_get_choice_menu - get the parent choice menu if present
* *
@ -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 *sym_get_choice_menu(const struct symbol *sym)
{ {
struct menu *menu = NULL; struct menu *menu = NULL;
struct menu *m;
/* /*
* Choice members must have a prompt. Find a menu entry with a prompt, * Choice members must have a prompt. Find a menu entry with a prompt,
* and assume it resides inside a choice block. * and assume it resides inside a choice block.
*/ */
list_for_each_entry(m, &sym->menus, link) menu = sym_get_prompt_menu(sym);
if (m->prompt) {
menu = m;
break;
}
if (!menu) if (!menu)
return NULL; return NULL;