From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/7] state: mark state init errors specially
Date: Thu, 25 Nov 2021 17:10:36 +0100 [thread overview]
Message-ID: <20211125161042.3829996-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20211125161042.3829996-1-a.fatoum@pengutronix.de>
First boot with uninitialized state is needlessly verbose. As
preparation for making boot less noisy on fresh state, mark all the
error messages with newly introduced dev_err_state_init().
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
common/state/backend_format_raw.c | 3 +--
common/state/backend_storage.c | 7 ++-----
common/state/state.c | 4 ++--
common/state/state.h | 7 +++++++
4 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/common/state/backend_format_raw.c b/common/state/backend_format_raw.c
index ea962606ccdb..aeee41d07ce9 100644
--- a/common/state/backend_format_raw.c
+++ b/common/state/backend_format_raw.c
@@ -116,9 +116,8 @@ static int backend_format_raw_verify(struct state_backend_format *format,
header = (struct backend_raw_header *)buf;
crc = crc32(0, header, sizeof(*header) - sizeof(uint32_t));
if (crc != header->header_crc) {
- dev_err(backend_raw->dev, "Error, invalid header crc in raw format, calculated 0x%08x, found 0x%08x\n",
+ return dev_err_state_init(backend_raw->dev, -EINVAL, "header crc in raw format, calculated 0x%08x, found 0x%08x\n",
crc, header->header_crc);
- return -EINVAL;
}
if (magic && magic != header->magic) {
diff --git a/common/state/backend_storage.c b/common/state/backend_storage.c
index 7fc7acfdcbc8..2d7d9a4a63c0 100644
--- a/common/state/backend_storage.c
+++ b/common/state/backend_storage.c
@@ -171,11 +171,8 @@ int state_storage_read(struct state_backend_storage *storage,
dev_dbg(storage->dev, "Checking redundant buckets finished.\n");
- if (!bucket_used) {
- dev_err(storage->dev, "Failed to find any valid state copy in any bucket\n");
-
- return -ENOENT;
- }
+ if (!bucket_used)
+ return dev_err_state_init(storage->dev, -ENOENT, "no valid state copy in any bucket\n");
dev_info(storage->dev, "Using bucket %d@0x%08llx\n", bucket_used->num, (long long) bucket_used->offset);
diff --git a/common/state/state.c b/common/state/state.c
index 469ee62d4012..8c34ae83e52b 100644
--- a/common/state/state.c
+++ b/common/state/state.c
@@ -101,8 +101,8 @@ static int state_do_load(struct state *state, enum state_flags flags)
ret = state_storage_read(&state->storage, state->format,
state->magic, &buf, &len, flags);
if (ret) {
- dev_err(&state->dev, "Failed to read state with format %s, %d\n",
- state->format->name, ret);
+ dev_err_state_init(&state->dev, ret, "format %s read failed\n",
+ state->format->name);
goto out;
}
diff --git a/common/state/state.h b/common/state/state.h
index 1881d92ea7fe..d858c9e42735 100644
--- a/common/state/state.h
+++ b/common/state/state.h
@@ -1,5 +1,6 @@
#include <linux/types.h>
#include <linux/list.h>
+#include <linux/err.h>
#include <driver.h>
struct state;
@@ -266,3 +267,9 @@ static inline int state_string_copy_to_raw(struct state_string *string,
return 0;
}
+
+#define dev_err_state_init(dev, ret, fmt, ...) ({ \
+ int __ret = (ret); \
+ dev_err((dev), "init error: %pe: " fmt, ERR_PTR(__ret), ##__VA_ARGS__); \
+ __ret; \
+})
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2021-11-25 16:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-25 16:10 [PATCH 0/7] ARM/RISC-V: qemu-virt: share common cleaned up state/env support Ahmad Fatoum
2021-11-25 16:10 ` Ahmad Fatoum [this message]
2021-11-25 16:10 ` [PATCH 2/7] state: make first boot less verbose Ahmad Fatoum
2021-11-30 10:47 ` Sascha Hauer
2021-11-30 13:52 ` Ahmad Fatoum
2021-11-25 16:10 ` [PATCH 3/7] of: overlay: rescan aliases calling of_overlay_apply_tree on live tree Ahmad Fatoum
2021-11-25 16:10 ` [PATCH 4/7] ARM: qemu: enable deep probe support Ahmad Fatoum
2021-11-25 16:10 ` [PATCH 5/7] ARM: qemu: move board code to central location Ahmad Fatoum
2021-11-25 16:10 ` [PATCH 6/7] common: boards: qemu-virt: genericize to support non-ARM architectures Ahmad Fatoum
2021-11-25 16:10 ` [PATCH 7/7] RISC-V: qemu-virt: add overlay for environment and state Ahmad Fatoum
2021-12-07 14:04 ` [PATCH 0/7] ARM/RISC-V: qemu-virt: share common cleaned up state/env support Sascha Hauer
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=20211125161042.3829996-2-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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