All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH 1/4] log: Add a flag to enable log drivers
Date: Sat, 12 Sep 2020 12:28:47 -0600	[thread overview]
Message-ID: <20200912122845.1.I35e547d3c773391e4102e3dbec0760c76fadd092@changeid> (raw)
In-Reply-To: <20200912182850.3909182-1-sjg@chromium.org>

At present there is no way to disable a log driver. But the syslog driver
causes (attempted) network traffic in sandbox every time a log message
is printed, which is often.

Add a flag to enable a log driver. Adjust struct log_device to use a short
for next_filter_num so that no more memory is used for devices. Also fix
a missing line in the struct log_driver comment while here.

To maintain compatibility, enable it for all drivers for now.

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

 common/log.c         |  4 +++-
 common/log_console.c |  1 +
 common/log_syslog.c  |  1 +
 include/log.h        | 11 ++++++++++-
 4 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/common/log.c b/common/log.c
index f44f15743ff..ce528fe4535 100644
--- a/common/log.c
+++ b/common/log.c
@@ -196,7 +196,8 @@ static int log_dispatch(struct log_rec *rec)
 	struct log_device *ldev;
 
 	list_for_each_entry(ldev, &gd->log_head, sibling_node) {
-		if (log_passes_filters(ldev, rec))
+		if ((ldev->flags & LOGDF_ENABLE) &&
+		    log_passes_filters(ldev, rec))
 			ldev->drv->emit(ldev, rec);
 	}
 
@@ -318,6 +319,7 @@ int log_init(void)
 		}
 		INIT_LIST_HEAD(&ldev->filter_head);
 		ldev->drv = drv;
+		ldev->flags = drv->flags;
 		list_add_tail(&ldev->sibling_node,
 			      (struct list_head *)&gd->log_head);
 		drv++;
diff --git a/common/log_console.c b/common/log_console.c
index bb3f8464b98..8776fd47039 100644
--- a/common/log_console.c
+++ b/common/log_console.c
@@ -44,4 +44,5 @@ static int log_console_emit(struct log_device *ldev, struct log_rec *rec)
 LOG_DRIVER(console) = {
 	.name	= "console",
 	.emit	= log_console_emit,
+	.flags	= LOGDF_ENABLE,
 };
diff --git a/common/log_syslog.c b/common/log_syslog.c
index 149ff5af310..cf0dbba9bf5 100644
--- a/common/log_syslog.c
+++ b/common/log_syslog.c
@@ -115,4 +115,5 @@ out:
 LOG_DRIVER(syslog) = {
 	.name	= "syslog",
 	.emit	= log_syslog_emit,
+	.flags	= LOGDF_ENABLE,
 };
diff --git a/include/log.h b/include/log.h
index 86c8d7be09d..d28bc1ef0e4 100644
--- a/include/log.h
+++ b/include/log.h
@@ -307,10 +307,16 @@ struct log_rec {
 
 struct log_device;
 
+enum log_device_flags {
+	LOGDF_ENABLE		= BIT(0),	/* Device is enabled */
+};
+
 /**
  * struct log_driver - a driver which accepts and processes log records
  *
  * @name: Name of driver
+ * @emit: Method to call to emit a log record via this device
+ * @flags: Initial value for flags (use LOGDF_ENABLE to enable on start-up)
  */
 struct log_driver {
 	const char *name;
@@ -321,6 +327,7 @@ struct log_driver {
 	 * for processing. The filter is checked before calling this function.
 	 */
 	int (*emit)(struct log_device *ldev, struct log_rec *rec);
+	unsigned short flags;
 };
 
 /**
@@ -333,12 +340,14 @@ struct log_driver {
  * @next_filter_num: Seqence number of next filter filter added (0=no filters
  *	yet). This increments with each new filter on the device, but never
  *	decrements
+ * @flags: Flags for this filter (enum log_device_flags)
  * @drv: Pointer to driver for this device
  * @filter_head: List of filters for this device
  * @sibling_node: Next device in the list of all devices
  */
 struct log_device {
-	int next_filter_num;
+	unsigned short next_filter_num;
+	unsigned short flags;
 	struct log_driver *drv;
 	struct list_head filter_head;
 	struct list_head sibling_node;
-- 
2.28.0.618.gf4bc123cb7-goog

  reply	other threads:[~2020-09-12 18:28 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-12 18:28 [PATCH 0/4] log: Fix the syslog spam when running tests Simon Glass
2020-09-12 18:28 ` Simon Glass [this message]
2020-10-12  1:14   ` [PATCH 1/4] log: Add a flag to enable log drivers Tom Rini
2020-09-12 18:28 ` [PATCH 2/4] log: Drop #ifdef in log_test Simon Glass
2020-10-12  1:14   ` Tom Rini
2020-09-12 18:28 ` [PATCH 3/4] log: Add a way to enable/disable a log device Simon Glass
2020-09-12 20:24   ` Heinrich Schuchardt
2020-09-13  1:24     ` Simon Glass
2020-10-12  1:15   ` Tom Rini
2020-09-12 18:28 ` [PATCH 4/4] log: Disable the syslog driver by default Simon Glass
2020-09-12 20:16   ` Heinrich Schuchardt
2020-09-12 20:24     ` Simon Glass
2020-09-12 20:34       ` Heinrich Schuchardt
2020-09-13  1:24         ` Simon Glass
2020-09-13  6:47           ` Heinrich Schuchardt
2020-09-13 13:26             ` Simon Glass
2020-10-12  1:15   ` Tom Rini
2020-09-14  8:24 ` [PATCH 0/4] log: Fix the syslog spam when running tests Heinrich Schuchardt

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=20200912122845.1.I35e547d3c773391e4102e3dbec0760c76fadd092@changeid \
    --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 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.