public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH v2 08/10] console: Always define the console-recording functions
Date: Sun,  7 Jun 2020 20:43:35 -0600	[thread overview]
Message-ID: <20200608024337.85575-3-sjg@chromium.org> (raw)
In-Reply-To: <20200608024337.85575-1-sjg@chromium.org>

On boards without console recording these function are currently missing.
It is more convenient for them to be present but to return dummy values.
That way if we know that a test needs recording, we can check if it is
available, and skip the test if not, while avoiding #ifdefs.

Update the header file according and adjust console_record_reset_enable()
to return an error if recording is not available.

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

(no changes since v1)

 common/console.c  |  4 +++-
 include/console.h | 39 ++++++++++++++++++++++++++++++++++++++-
 2 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/common/console.c b/common/console.c
index 1deca3cb78..719ab8a1a6 100644
--- a/common/console.c
+++ b/common/console.c
@@ -619,10 +619,12 @@ void console_record_reset(void)
 	membuff_purge((struct membuff *)&gd->console_in);
 }
 
-void console_record_reset_enable(void)
+int console_record_reset_enable(void)
 {
 	console_record_reset();
 	gd->flags |= GD_FLG_RECORD;
+
+	return 0;
 }
 
 int console_record_readline(char *str, int maxlen)
diff --git a/include/console.h b/include/console.h
index 74afe22b7e..74a41d953b 100644
--- a/include/console.h
+++ b/include/console.h
@@ -19,11 +19,14 @@ void clear_ctrlc(void);	/* clear the Control-C condition */
 int disable_ctrlc(int);	/* 1 to disable, 0 to enable Control-C detect */
 int confirm_yesno(void);        /*  1 if input is "y", "Y", "yes" or "YES" */
 
+#ifdef CONFIG_CONSOLE_RECORD
 /**
  * console_record_init() - set up the console recording buffers
  *
  * This should be called as soon as malloc() is available so that the maximum
  * amount of console output can be recorded.
+ *
+ * @return 0 if OK, -ENOMEM if out of memory
  */
 int console_record_init(void);
 
@@ -38,8 +41,10 @@ void console_record_reset(void);
  * console_record_reset_enable() - reset and enable the console buffers
  *
  * This should be called to enable the console buffer.
+ *
+ * @return 0 (always)
  */
-void console_record_reset_enable(void);
+int console_record_reset_enable(void);
 
 /**
  * console_record_readline() - Read a line from the console output
@@ -59,6 +64,38 @@ int console_record_readline(char *str, int maxlen);
  * @return available bytes (0 if empty)
  */
 int console_record_avail(void);
+#else
+static inline int console_record_init(void)
+{
+	/* Always succeed, since it is not enabled */
+
+	return 0;
+}
+
+static inline void console_record_reset(void)
+{
+	/* Nothing to do here */
+}
+
+static inline int console_record_reset_enable(void)
+{
+	/* Cannot enable it as it is not supported */
+	return -ENOSYS;
+}
+
+static inline int console_record_readline(char *str, int maxlen)
+{
+	/* Nothing to read */
+	return 0;
+}
+
+static inline int console_record_avail(void)
+{
+	/* There is never anything available */
+	return 0;
+}
+
+#endif /* !CONFIG_CONSOLE_RECORD */
 
 /**
  * console_announce_r() - print a U-Boot console on non-serial consoles
-- 
2.27.0.278.ge193c7cf3a9-goog

  parent reply	other threads:[~2020-06-08  2:43 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-08  2:43 [PATCH v2 00/10] cmd: Fix 'md' and add a memory-search command Simon Glass
2020-06-08  2:43 ` [PATCH v2 01/10] Update MEM_SUPPORT_64BIT_DATA to be always defined Simon Glass
2020-06-08  2:43 ` [PATCH v2 02/10] cmd: mem: Use a macro to avoid #ifdef in help Simon Glass
2020-06-08  2:43 ` [PATCH v2 03/10] cmd: mem: Drop #ifdef for MEM_SUPPORT_64BIT_DATA Simon Glass
2020-06-08  2:43 ` [PATCH v2 04/10] display_options: " Simon Glass
2020-06-08  2:43 ` [PATCH v2 05/10] command: " Simon Glass
2020-06-08  2:43 ` [PATCH v2 06/10] test: Add a way to check part of a console line or skip it Simon Glass
2020-06-08  2:43 ` [PATCH v2 07/10] dm: test: Rename test flags to be generic Simon Glass
2020-06-08  2:43 ` Simon Glass [this message]
2020-06-08  2:43 ` [PATCH v2 09/10] test: Add a flag for tests that need console recording Simon Glass
2020-06-08  2:43 ` [PATCH v2 10/10] cmd: Add a memory-search command 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=20200608024337.85575-3-sjg@chromium.org \
    --to=sjg@chromium.org \
    --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