u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>
Subject: [PATCH v2 12/27] Move bootmenu_conv_key() into its own file
Date: Sat,  7 Oct 2023 17:12:31 -0600	[thread overview]
Message-ID: <20231007231255.277623-13-sjg@chromium.org> (raw)
In-Reply-To: <20231007231255.277623-1-sjg@chromium.org>

This conversion function is used by expo which does not require CMDLINE.
The menu feature does require CMDLINE.

Move the function into a separate file so that it can be used even when
CMDLINE is not enabled.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 common/Makefile    |  2 +-
 common/cli_getch.c |  1 +
 common/menu.c      | 40 -------------------------------------
 common/menu_key.c  | 49 ++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 51 insertions(+), 41 deletions(-)
 create mode 100644 common/menu_key.c

diff --git a/common/Makefile b/common/Makefile
index b21916f15340..637066ae6682 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -8,7 +8,7 @@ ifndef CONFIG_SPL_BUILD
 obj-y += init/
 obj-y += main.o
 obj-y += exports.o
-obj-y += cli_getch.o
+obj-y += cli_getch.o menu_key.o
 obj-$(CONFIG_HUSH_PARSER) += cli_hush.o
 obj-$(CONFIG_AUTOBOOT) += autoboot.o
 
diff --git a/common/cli_getch.c b/common/cli_getch.c
index 61d4cb261b81..c3332dc27fae 100644
--- a/common/cli_getch.c
+++ b/common/cli_getch.c
@@ -8,6 +8,7 @@
 
 #include <common.h>
 #include <cli.h>
+#include <menu.h>
 
 /**
  * enum cli_esc_state_t - indicates what to do with an escape character
diff --git a/common/menu.c b/common/menu.c
index b55cf7b99967..844d0ec52af3 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -483,46 +483,6 @@ enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu,
 	return key;
 }
 
-enum bootmenu_key bootmenu_conv_key(int ichar)
-{
-	enum bootmenu_key key;
-
-	switch (ichar) {
-	case '\n':
-		/* enter key was pressed */
-		key = BKEY_SELECT;
-		break;
-	case CTL_CH('c'):
-	case '\e':
-		/* ^C was pressed */
-		key = BKEY_QUIT;
-		break;
-	case CTL_CH('p'):
-		key = BKEY_UP;
-		break;
-	case CTL_CH('n'):
-		key = BKEY_DOWN;
-		break;
-	case CTL_CH('s'):
-		key = BKEY_SAVE;
-		break;
-	case '+':
-		key = BKEY_PLUS;
-		break;
-	case '-':
-		key = BKEY_MINUS;
-		break;
-	case ' ':
-		key = BKEY_SPACE;
-		break;
-	default:
-		key = BKEY_NONE;
-		break;
-	}
-
-	return key;
-}
-
 enum bootmenu_key bootmenu_loop(struct bootmenu_data *menu,
 				struct cli_ch_state *cch)
 {
diff --git a/common/menu_key.c b/common/menu_key.c
new file mode 100644
index 000000000000..4e9c3b426b0c
--- /dev/null
+++ b/common/menu_key.c
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2010-2011 Calxeda, Inc.
+ * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
+ */
+
+#include <common.h>
+#include <cli.h>
+#include <menu.h>
+
+enum bootmenu_key bootmenu_conv_key(int ichar)
+{
+	enum bootmenu_key key;
+
+	switch (ichar) {
+	case '\n':
+		/* enter key was pressed */
+		key = BKEY_SELECT;
+		break;
+	case CTL_CH('c'):
+	case '\e':
+		/* ^C was pressed */
+		key = BKEY_QUIT;
+		break;
+	case CTL_CH('p'):
+		key = BKEY_UP;
+		break;
+	case CTL_CH('n'):
+		key = BKEY_DOWN;
+		break;
+	case CTL_CH('s'):
+		key = BKEY_SAVE;
+		break;
+	case '+':
+		key = BKEY_PLUS;
+		break;
+	case '-':
+		key = BKEY_MINUS;
+		break;
+	case ' ':
+		key = BKEY_SPACE;
+		break;
+	default:
+		key = BKEY_NONE;
+		break;
+	}
+
+	return key;
+}
-- 
2.42.0.609.gbb76f46606-goog


  parent reply	other threads:[~2023-10-07 23:26 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-07 23:12 [PATCH v2 00/27] Tidy up use of CONFIG_CMDLINE Simon Glass
2023-10-07 23:12 ` [PATCH v2 01/27] command.h: Add a U_BOOT_LONGHELP macro Simon Glass
2023-10-07 23:12 ` [PATCH v2 02/27] cmd: Convert existing long help messages to the new macro Simon Glass
2023-10-07 23:12 ` [PATCH v2 03/27] buildman: Use oldconfig when adjusting the config Simon Glass
2023-10-07 23:12 ` [PATCH v2 04/27] bootstd: Correct dependencies on CMDLINE Simon Glass
2023-10-07 23:32   ` Tom Rini
2023-10-07 23:45     ` Simon Glass
2023-10-09 14:36       ` Tom Rini
2023-10-07 23:12 ` [PATCH v2 05/27] autoboot: " Simon Glass
2023-10-09 14:35   ` Tom Rini
2023-10-07 23:12 ` [PATCH v2 06/27] cmd: Add a few more " Simon Glass
2023-10-09 14:36   ` Tom Rini
2023-10-07 23:12 ` [PATCH v2 07/27] test: Make UNIT_TEST depend " Simon Glass
2023-10-09 14:36   ` Tom Rini
2023-10-07 23:12 ` [PATCH v2 08/27] sifive: Change #ifdef for nop Simon Glass
2023-10-09 14:36   ` Tom Rini
2023-10-07 23:12 ` [PATCH v2 09/27] fastboot: Declare a dependency on CMDLINE Simon Glass
2023-10-07 23:12 ` [PATCH v2 10/27] cli: Always build cli_getch Simon Glass
2023-10-07 23:12 ` [PATCH v2 11/27] cmd: Use an #ifdef around run_commandf() Simon Glass
2023-10-07 23:12 ` Simon Glass [this message]
2023-10-07 23:12 ` [PATCH v2 13/27] pxe: Depend on CMDLINE Simon Glass
2023-10-07 23:12 ` [PATCH v2 14/27] env: Split out non-command code into a new file Simon Glass
2023-10-07 23:12 ` [PATCH v2 15/27] console: Move SYS_PBSIZE into common/ Simon Glass
2023-10-07 23:12 ` [PATCH v2 16/27] bootm: Allow building when cleanup functions are missing Simon Glass
2023-10-07 23:12 ` [PATCH v2 17/27] fdt: Move working_fdt into fdt_support Simon Glass
2023-10-07 23:12 ` [PATCH v2 18/27] net: Depend on CONFIG_CMDLINE Simon Glass
2023-10-07 23:12 ` [PATCH v2 19/27] log: Allow use without CONFIG_CMDLINE Simon Glass
2023-10-07 23:12 ` [PATCH v2 20/27] video: " Simon Glass
2023-10-07 23:12 ` [PATCH v2 21/27] video: Dont require the font command Simon Glass
2023-10-07 23:12 ` [PATCH v2 22/27] efi: Depend on CMDLINE for efi_loader Simon Glass
2023-10-10  4:48   ` AKASHI Takahiro
2023-10-07 23:12 ` [PATCH v2 23/27] cmd: Make all commands depend on CMDLINE Simon Glass
2023-10-07 23:12 ` [PATCH v2 24/27] sandbox: Avoid requiring cmdline Simon Glass
2023-10-07 23:12 ` [PATCH v2 25/27] arm: x86: Drop discarding of command linker-lists Simon Glass
2023-10-07 23:12 ` [PATCH v2 26/27] mmc: env: Unify the U_BOOT_ENV_LOCATION conditions Simon Glass
2023-10-07 23:12 ` [PATCH v2 27/27] sandbox: Add a test for disabling CONFIG_CMDLINE Simon Glass

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=20231007231255.277623-13-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).