]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
kconfig: re-add menu_get_parent_menu() that returns parent menu
authorMasahiro Yamada <masahiroy@kernel.org>
Tue, 24 Jun 2025 15:04:53 +0000 (00:04 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Mon, 30 Jun 2025 04:20:23 +0000 (13:20 +0900)
This helper returns the parent menu, or NULL if there is no parent.
The main difference from the previous version is that it always returns
the parent menu even when the given argument is itself a menu.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
scripts/kconfig/lkc.h
scripts/kconfig/menu.c

index 5cc85c3d4aaaf6b770bfd77986e968b816a9ae9c..37b606c74bff3a1dd741fde0d60e716029d2830c 100644 (file)
@@ -97,6 +97,7 @@ bool menu_is_empty(struct menu *menu);
 bool menu_is_visible(struct menu *menu);
 bool menu_has_prompt(const struct menu *menu);
 const char *menu_get_prompt(const struct menu *menu);
+struct menu *menu_get_parent_menu(struct menu *menu);
 struct menu *menu_get_menu_or_parent_menu(struct menu *menu);
 int get_jump_key_char(void);
 struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head);
index ccb690bbf05d61176a2741bb23e0bfe981a3641d..a5e5b4fdcd935534cf6f2aae4d568096acae8b9a 100644 (file)
@@ -575,6 +575,20 @@ const char *menu_get_prompt(const struct menu *menu)
        return NULL;
 }
 
+/**
+ * menu_get_parent_menu - return the parent menu or NULL
+ * @menu: pointer to the menu
+ * return: the parent menu, or NULL if there is no parent.
+ */
+struct menu *menu_get_parent_menu(struct menu *menu)
+{
+       for (menu = menu->parent; menu; menu = menu->parent)
+               if (menu->type == M_MENU)
+                       return menu;
+
+       return NULL;
+}
+
 /**
  * menu_get_menu_or_parent_menu - return the parent menu or the menu itself
  * @menu: pointer to the menu