diff mbox series

[14/14] smbios: Correct error handling when writing tables

Message ID 20240623203033.1566505-15-sjg@chromium.org
State Accepted
Commit 4a8a54c3f4202482ec4f24a117afc38cf2c0c051
Delegated to: Tom Rini
Headers show
Series testb: Various tweaks and fixes for Labgrid | expand

Commit Message

Simon Glass June 23, 2024, 8:30 p.m. UTC
Since write_smbios_table() returns an address, we cannot use it to
return and error number. Also, failing on sysinfo_detect() breaks
existing boards, e.g. chromebook_link

Correct this by logging and swallowing the error.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: a5a57562856 ("lib: smbios: Detect system properties via...")
---

(no changes since v1)

 lib/smbios.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Heinrich Schuchardt June 24, 2024, 4:36 a.m. UTC | #1
Am 23. Juni 2024 22:30:33 MESZ schrieb Simon Glass <sjg@chromium.org>:
>Since write_smbios_table() returns an address, we cannot use it to
>return and error number. Also, failing on sysinfo_detect() breaks

IS_ERR_VALUE() could serve as template for conveying errors in addresses.



>existing boards, e.g. chromebook_link
>
>Correct this by logging and swallowing the error.
>
>Signed-off-by: Simon Glass <sjg@chromium.org>
>Fixes: a5a57562856 ("lib: smbios: Detect system properties via...")
>---
>
>(no changes since v1)
>
> lib/smbios.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
>diff --git a/lib/smbios.c b/lib/smbios.c
>index fb6eaf1d5ca..4126466e34a 100644
>--- a/lib/smbios.c
>+++ b/lib/smbios.c
>@@ -5,6 +5,8 @@
>  * Adapted from coreboot src/arch/x86/smbios.c
>  */
> 
>+#define LOG_CATEGORY	LOGC_BOARD
>+
> #include <dm.h>
> #include <env.h>
> #include <linux/stringify.h>
>@@ -596,8 +598,12 @@ ulong write_smbios_table(ulong addr)
> 
> 			parent_node = dev_read_subnode(ctx.dev, "smbios");
> 			ret = sysinfo_detect(ctx.dev);
>-			if (ret)
>-				return ret;
>+
>+			/*
>+			 * ignore the error since many boards don't implement
>+			 * this and we can still use the info in the devicetree
>+			 */
>+			ret = log_msg_ret("sys", ret);

Can we make this a debug message?
It is nothing an end user should worry about.

Best regards

Heinrich

> 		}
> 	} else {
> 		ctx.dev = NULL;
Simon Glass June 25, 2024, 12:30 p.m. UTC | #2
Hi Heinrich,

On Sun, 23 Jun 2024 at 22:41, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
>
>
> Am 23. Juni 2024 22:30:33 MESZ schrieb Simon Glass <sjg@chromium.org>:
> >Since write_smbios_table() returns an address, we cannot use it to
> >return and error number. Also, failing on sysinfo_detect() breaks
>
> IS_ERR_VALUE() could serve as template for conveying errors in addresses.
>
>
>
> >existing boards, e.g. chromebook_link
> >
> >Correct this by logging and swallowing the error.
> >
> >Signed-off-by: Simon Glass <sjg@chromium.org>
> >Fixes: a5a57562856 ("lib: smbios: Detect system properties via...")
> >---
> >
> >(no changes since v1)
> >
> > lib/smbios.c | 10 ++++++++--
> > 1 file changed, 8 insertions(+), 2 deletions(-)
> >
> >diff --git a/lib/smbios.c b/lib/smbios.c
> >index fb6eaf1d5ca..4126466e34a 100644
> >--- a/lib/smbios.c
> >+++ b/lib/smbios.c
> >@@ -5,6 +5,8 @@
> >  * Adapted from coreboot src/arch/x86/smbios.c
> >  */
> >
> >+#define LOG_CATEGORY  LOGC_BOARD
> >+
> > #include <dm.h>
> > #include <env.h>
> > #include <linux/stringify.h>
> >@@ -596,8 +598,12 @@ ulong write_smbios_table(ulong addr)
> >
> >                       parent_node = dev_read_subnode(ctx.dev, "smbios");
> >                       ret = sysinfo_detect(ctx.dev);
> >-                      if (ret)
> >-                              return ret;
> >+
> >+                      /*
> >+                       * ignore the error since many boards don't implement
> >+                       * this and we can still use the info in the devicetree
> >+                       */
> >+                      ret = log_msg_ret("sys", ret);
>
> Can we make this a debug message?
> It is nothing an end user should worry about.

Yes, this is a debug message...it will only print if you have
CONFIG_LOG_ERROR_RETURN enabled.

Regards,
Simon
diff mbox series

Patch

diff --git a/lib/smbios.c b/lib/smbios.c
index fb6eaf1d5ca..4126466e34a 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -5,6 +5,8 @@ 
  * Adapted from coreboot src/arch/x86/smbios.c
  */
 
+#define LOG_CATEGORY	LOGC_BOARD
+
 #include <dm.h>
 #include <env.h>
 #include <linux/stringify.h>
@@ -596,8 +598,12 @@  ulong write_smbios_table(ulong addr)
 
 			parent_node = dev_read_subnode(ctx.dev, "smbios");
 			ret = sysinfo_detect(ctx.dev);
-			if (ret)
-				return ret;
+
+			/*
+			 * ignore the error since many boards don't implement
+			 * this and we can still use the info in the devicetree
+			 */
+			ret = log_msg_ret("sys", ret);
 		}
 	} else {
 		ctx.dev = NULL;