grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v3 2/6] kern/term: Make grub_getkeystatus helper function availab


From: Javier Martinez Canillas
Subject: [PATCH v3 2/6] kern/term: Make grub_getkeystatus helper function available everywhere
Date: Wed, 15 Apr 2020 12:26:18 +0200

From: Hans de Goede <address@hidden>

Move grub_getkeystatushelper function from grub-core/commands/keystatus.c
to grub-core/kern/term.c and export it so that it can be used outside of
the keystatus command code too.

There's no logic change in this patch. The function definition is moved so
it can be called from grub-core/kern/term.c in a subsequent patch. It will
be used to determine if a SHIFT key has was held down and use that also to
interrupt the countdown, without the need to press a key at the right time.

Signed-off-by: Hans de Goede <address@hidden>
Signed-off-by: Javier Martinez Canillas <address@hidden>
Reviewed-by: Daniel Kiper <address@hidden>
---

Changes in v3: None
Changes in v2:
- Also mention in commit message that logic is unchanged after patch #2.
- Explain why the helper function needs to be available for other modules.
- Move patch #2 earlier in the patch-set since is a proparatory change.

 grub-core/commands/keystatus.c | 18 ------------------
 grub-core/kern/term.c          | 18 ++++++++++++++++++
 include/grub/term.h            |  1 +
 3 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/grub-core/commands/keystatus.c b/grub-core/commands/keystatus.c
index 460cf4e7e50..ff3f5878163 100644
--- a/grub-core/commands/keystatus.c
+++ b/grub-core/commands/keystatus.c
@@ -35,24 +35,6 @@ static const struct grub_arg_option options[] =
     {0, 0, 0, 0, 0, 0}
   };
 
-static int
-grub_getkeystatus (void)
-{
-  int status = 0;
-  grub_term_input_t term;
-
-  if (grub_term_poll_usb)
-    grub_term_poll_usb (0);
-
-  FOR_ACTIVE_TERM_INPUTS(term)
-  {
-    if (term->getkeystatus)
-      status |= term->getkeystatus (term);
-  }
-
-  return status;
-}
-
 static grub_err_t
 grub_cmd_keystatus (grub_extcmd_context_t ctxt,
                    int argc __attribute__ ((unused)),
diff --git a/grub-core/kern/term.c b/grub-core/kern/term.c
index 07720ee6746..93bd3378d18 100644
--- a/grub-core/kern/term.c
+++ b/grub-core/kern/term.c
@@ -120,6 +120,24 @@ grub_getkey (void)
     }
 }
 
+int
+grub_getkeystatus (void)
+{
+  int status = 0;
+  grub_term_input_t term;
+
+  if (grub_term_poll_usb)
+    grub_term_poll_usb (0);
+
+  FOR_ACTIVE_TERM_INPUTS(term)
+  {
+    if (term->getkeystatus)
+      status |= term->getkeystatus (term);
+  }
+
+  return status;
+}
+
 void
 grub_refresh (void)
 {
diff --git a/include/grub/term.h b/include/grub/term.h
index 8117e2a24da..c215133383f 100644
--- a/include/grub/term.h
+++ b/include/grub/term.h
@@ -327,6 +327,7 @@ grub_term_unregister_output (grub_term_output_t term)
 void grub_putcode (grub_uint32_t code, struct grub_term_output *term);
 int EXPORT_FUNC(grub_getkey) (void);
 int EXPORT_FUNC(grub_getkey_noblock) (void);
+int EXPORT_FUNC(grub_getkeystatus) (void);
 void grub_cls (void);
 void EXPORT_FUNC(grub_refresh) (void);
 void grub_puts_terminal (const char *str, struct grub_term_output *term);
-- 
2.25.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]