diff mbox series

[v2,1/3] log: move processing_msg to global data

Message ID 20201017123159.172357-2-xypron.glpk@gmx.de
State Accepted
Commit 993a06b6144d54ae2ad83cc25c18acb9d1720ad0
Delegated to: Tom Rini
Headers show
Series log: allow for message continuation | expand

Commit Message

Heinrich Schuchardt Oct. 17, 2020, 12:31 p.m. UTC
Replace the static variable processing_msg by a field in the global data.
Make the field bool at it can only be true or false.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
v2:
	new patch
---
 common/log.c                      | 7 +++----
 include/asm-generic/global_data.h | 8 ++++++++
 2 files changed, 11 insertions(+), 4 deletions(-)

--
2.28.0

Comments

Simon Glass Oct. 27, 2020, 4:52 a.m. UTC | #1
On Sat, 17 Oct 2020 at 06:32, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> Replace the static variable processing_msg by a field in the global data.
> Make the field bool at it can only be true or false.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
> v2:
>         new patch
> ---
>  common/log.c                      | 7 +++----
>  include/asm-generic/global_data.h | 8 ++++++++
>  2 files changed, 11 insertions(+), 4 deletions(-)
>

Reviewed-by: Simon Glass <sjg@chromium.org>
Tom Rini Oct. 28, 2020, 3:31 p.m. UTC | #2
On Sat, Oct 17, 2020 at 02:31:57PM +0200, Heinrich Schuchardt wrote:

> Replace the static variable processing_msg by a field in the global data.
> Make the field bool at it can only be true or false.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/common/log.c b/common/log.c
index 1b10f6f180..f95f09c1b6 100644
--- a/common/log.c
+++ b/common/log.c
@@ -194,24 +194,23 @@  static bool log_passes_filters(struct log_device *ldev, struct log_rec *rec)
 static int log_dispatch(struct log_rec *rec)
 {
 	struct log_device *ldev;
-	static int processing_msg;

 	/*
 	 * When a log driver writes messages (e.g. via the network stack) this
 	 * may result in further generated messages. We cannot process them here
 	 * as this might result in infinite recursion.
 	 */
-	if (processing_msg)
+	if (gd->processing_msg)
 		return 0;

 	/* Emit message */
-	processing_msg = 1;
+	gd->processing_msg = true;
 	list_for_each_entry(ldev, &gd->log_head, sibling_node) {
 		if ((ldev->flags & LOGDF_ENABLE) &&
 		    log_passes_filters(ldev, rec))
 			ldev->drv->emit(ldev, rec);
 	}
-	processing_msg = 0;
+	gd->processing_msg = false;
 	return 0;
 }

diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h
index ebb740d34f..db83f59ceb 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -363,6 +363,14 @@  struct global_data {
 	 * &enum log_fmt defines the bits of the bit mask.
 	 */
 	int log_fmt;
+
+	/**
+	 * @processing_msg: a log message is being processed
+	 *
+	 * This flag is used to suppress the creation of additional messages
+	 * while another message is being processed.
+	 */
+	bool processing_msg;
 #endif
 #if CONFIG_IS_ENABLED(BLOBLIST)
 	/**