Skip to content

Commit bce590f

Browse files
committed
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 <[email protected]>
1 parent 929ce50 commit bce590f

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

scripts/kconfig/lkc_proto.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ bool sym_string_valid(struct symbol *sym, const char *newval);
3434
bool sym_string_within_range(struct symbol *sym, const char *str);
3535
bool sym_set_string_value(struct symbol *sym, const char *newval);
3636
bool sym_is_changeable(const struct symbol *sym);
37+
struct menu *sym_get_prompt_menu(const struct symbol *sym);
3738
struct menu *sym_get_choice_menu(const struct symbol *sym);
3839
const char * sym_get_string_value(struct symbol *sym);
3940

scripts/kconfig/symbol.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,24 @@ const char *sym_type_name(enum symbol_type type)
7070
return "???";
7171
}
7272

73+
/**
74+
* sym_get_prompt_menu - get the menu entry with a prompt
75+
*
76+
* @sym: a symbol pointer
77+
*
78+
* Return: the menu entry with a prompt.
79+
*/
80+
struct menu *sym_get_prompt_menu(const struct symbol *sym)
81+
{
82+
struct menu *m;
83+
84+
list_for_each_entry(m, &sym->menus, link)
85+
if (m->prompt)
86+
return m;
87+
88+
return NULL;
89+
}
90+
7391
/**
7492
* sym_get_choice_menu - get the parent choice menu if present
7593
*
@@ -80,18 +98,12 @@ const char *sym_type_name(enum symbol_type type)
8098
struct menu *sym_get_choice_menu(const struct symbol *sym)
8199
{
82100
struct menu *menu = NULL;
83-
struct menu *m;
84101

85102
/*
86103
* Choice members must have a prompt. Find a menu entry with a prompt,
87104
* and assume it resides inside a choice block.
88105
*/
89-
list_for_each_entry(m, &sym->menus, link)
90-
if (m->prompt) {
91-
menu = m;
92-
break;
93-
}
94-
106+
menu = sym_get_prompt_menu(sym);
95107
if (!menu)
96108
return NULL;
97109

0 commit comments

Comments
 (0)