Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kconfig: add sym_get_choice_menu() helper

Choices and their members are associated via the P_CHOICE property.

Currently, prop_get_symbol(sym_get_choice_prop()) is used to obtain
the choice of the given choice member.

We can do this without relying on P_CHOICE by checking the parent in
the menu structure.

Introduce a new helper to retrieve the choice if the given symbol is a
choice member.

This is intended to replace prop_get_symbol(sym_get_choice_prop()) and
deprecate P_CHOICE eventually.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

+36
+1
scripts/kconfig/lkc_proto.h
··· 34 34 bool sym_set_string_value(struct symbol *sym, const char *newval); 35 35 bool sym_is_changeable(struct symbol *sym); 36 36 struct property * sym_get_choice_prop(struct symbol *sym); 37 + struct menu *sym_get_choice_menu(struct symbol *sym); 37 38 const char * sym_get_string_value(struct symbol *sym); 38 39 39 40 const char * prop_get_type_name(enum prop_type type);
+35
scripts/kconfig/symbol.c
··· 78 78 return NULL; 79 79 } 80 80 81 + /** 82 + * sym_get_choice_menu - get the parent choice menu if present 83 + * 84 + * @sym: a symbol pointer 85 + * 86 + * Return: a choice menu if this function is called against a choice member. 87 + */ 88 + struct menu *sym_get_choice_menu(struct symbol *sym) 89 + { 90 + struct menu *menu = NULL; 91 + struct menu *m; 92 + 93 + /* 94 + * Choice members must have a prompt. Find a menu entry with a prompt, 95 + * and assume it resides inside a choice block. 96 + */ 97 + list_for_each_entry(m, &sym->menus, link) 98 + if (m->prompt) { 99 + menu = m; 100 + break; 101 + } 102 + 103 + if (!menu) 104 + return NULL; 105 + 106 + do { 107 + menu = menu->parent; 108 + } while (menu && !menu->sym); 109 + 110 + if (menu && menu->sym && sym_is_choice(menu->sym)) 111 + return menu; 112 + 113 + return NULL; 114 + } 115 + 81 116 static struct property *sym_get_default_prop(struct symbol *sym) 82 117 { 83 118 struct property *prop;