]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
kconfig: add sym_get_prompt_menu() helper function
authorMasahiro Yamada <masahiroy@kernel.org>
Wed, 23 Oct 2024 18:18:01 +0000 (03:18 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Tue, 5 Nov 2024 23:46:34 +0000 (08:46 +0900)
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>
scripts/kconfig/lkc_proto.h
scripts/kconfig/symbol.c

index 63519cd24bc7fa8e30c03b712e85e1a22fe0984d..8914b4e8f2a81161844aace81ece38fb97d7ce7e 100644 (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_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);
 
index a3af93aaaf32af1e1a1a62433888303b30bd7182..89b84bf8e21fa63e6ca2482561017c8508910717 100644 (file)
@@ -70,6 +70,24 @@ const char *sym_type_name(enum symbol_type type)
        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
  *
@@ -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;