All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: Masahiro Yamada <masahiroy@kernel.org>, linux-kernel@vger.kernel.org
Subject: [PATCH 11/13] kconfig: add sym_get_prompt_menu() helper function
Date: Thu, 24 Oct 2024 03:18:01 +0900	[thread overview]
Message-ID: <20241023181823.138524-11-masahiroy@kernel.org> (raw)
In-Reply-To: <20241023181823.138524-1-masahiroy@kernel.org>

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 |  1 +
 scripts/kconfig/symbol.c    | 26 +++++++++++++++++++-------
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index 63519cd24bc7..8914b4e8f2a8 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -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);
 
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index a3af93aaaf32..89b84bf8e21f 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -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;
 
-- 
2.43.0


  parent reply	other threads:[~2024-10-23 18:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-23 18:17 [PATCH 01/13] kconfig: qconf: remove mouse{Press,Move}Event() functions Masahiro Yamada
2024-10-23 18:17 ` [PATCH 02/13] kconfig: qconf: remove redundant type check for choice members Masahiro Yamada
2024-10-23 18:17 ` [PATCH 03/13] kconfig: qconf: remove unnecessary setRootIsDecorated() call Masahiro Yamada
2024-10-23 18:17 ` [PATCH 04/13] kconfig: qconf: remove unnecessary lastWindowClosed() signal connection Masahiro Yamada
2024-10-23 18:17 ` [PATCH 05/13] kconfig: qconf: convert the last old connection syntax to Qt5 style Masahiro Yamada
2024-10-23 18:17 ` [PATCH 06/13] kconfig: qconf: do not show goParent button in split view Masahiro Yamada
2024-10-23 18:17 ` [PATCH 07/13] kconfig: qconf: remove ConfigItem::visible member Masahiro Yamada
2024-10-23 18:17 ` [PATCH 08/13] kconfig: qconf: avoid unnecessary parentSelected() when ESC is pressed Masahiro Yamada
2024-10-23 18:17 ` [PATCH 09/13] kconfig: qconf: remove redundant check in goBack() Masahiro Yamada
2024-10-23 18:18 ` [PATCH 10/13] kconfig: qconf: remove non-functional href="m..." tag Masahiro Yamada
2024-10-23 18:18 ` Masahiro Yamada [this message]
2024-10-23 18:18 ` [PATCH 12/13] kconfig: qconf: refactor ConfigInfoView::clicked() Masahiro Yamada
2024-10-23 18:18 ` [PATCH 13/13] kconfig: qconf: remove unnecessary mode check in ConfigItem::updateMenu() Masahiro Yamada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241023181823.138524-11-masahiroy@kernel.org \
    --to=masahiroy@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.