[PATCH v1] firmware: scmi: dump error string

alice.guo at oss.nxp.com alice.guo at oss.nxp.com
Sun Oct 6 09:13:17 CEST 2024


From: Peng Fan <peng.fan at nxp.com>

When error happends, dump string is more intuitive.

Signed-off-by: Peng Fan <peng.fan at nxp.com>
Signed-off-by: Alice Guo <alice.guo at nxp.com>
Reviewed-by: Ye Li <ye.li at nxp.com>
---
 drivers/firmware/scmi/scmi_agent-uclass.c | 26 +++++++++++++----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/firmware/scmi/scmi_agent-uclass.c b/drivers/firmware/scmi/scmi_agent-uclass.c
index 8c907c3b03..e2d42d2914 100644
--- a/drivers/firmware/scmi/scmi_agent-uclass.c
+++ b/drivers/firmware/scmi/scmi_agent-uclass.c
@@ -18,23 +18,25 @@
  * struct error_code - Helper structure for SCMI error code conversion
  * @scmi:	SCMI error code
  * @errno:	Related standard error number
+ * @string:	Name the scmi error code
  */
 struct error_code {
 	int scmi;
 	int errno;
+	char *string;
 };
 
 static const struct error_code scmi_linux_errmap[] = {
-	{ .scmi = SCMI_NOT_SUPPORTED, .errno = -EOPNOTSUPP, },
-	{ .scmi = SCMI_INVALID_PARAMETERS, .errno = -EINVAL, },
-	{ .scmi = SCMI_DENIED, .errno = -EACCES, },
-	{ .scmi = SCMI_NOT_FOUND, .errno = -ENOENT, },
-	{ .scmi = SCMI_OUT_OF_RANGE, .errno = -ERANGE, },
-	{ .scmi = SCMI_BUSY, .errno = -EBUSY, },
-	{ .scmi = SCMI_COMMS_ERROR, .errno = -ECOMM, },
-	{ .scmi = SCMI_GENERIC_ERROR, .errno = -EIO, },
-	{ .scmi = SCMI_HARDWARE_ERROR, .errno = -EREMOTEIO, },
-	{ .scmi = SCMI_PROTOCOL_ERROR, .errno = -EPROTO, },
+	{ .scmi = SCMI_NOT_SUPPORTED, .errno = -EOPNOTSUPP, .string = "SCMI_NOT_SUPPORTED" },
+	{ .scmi = SCMI_INVALID_PARAMETERS, .errno = -EINVAL, .string = "SCMI_INVALID_PARAMETERS" },
+	{ .scmi = SCMI_DENIED, .errno = -EACCES, .string = "SCMI_DENIED" },
+	{ .scmi = SCMI_NOT_FOUND, .errno = -ENOENT, .string = "SCMI_NOT_SUPPORTED" },
+	{ .scmi = SCMI_OUT_OF_RANGE, .errno = -ERANGE, .string = "SCMI_OUT_OF_RANGE" },
+	{ .scmi = SCMI_BUSY, .errno = -EBUSY, .string = "SCMI_BUSY" },
+	{ .scmi = SCMI_COMMS_ERROR, .errno = -ECOMM, .string = "SCMI_COMMS_ERROR" },
+	{ .scmi = SCMI_GENERIC_ERROR, .errno = -EIO, .string = "SCMI_GENERIC_ERROR" },
+	{ .scmi = SCMI_HARDWARE_ERROR, .errno = -EREMOTEIO, .string = "SCMI_HARDWARE_ERROR" },
+	{ .scmi = SCMI_PROTOCOL_ERROR, .errno = -EPROTO, .string = "SCMI_PROTOCOL_ERROR" },
 };
 
 /**
@@ -163,8 +165,10 @@ int scmi_to_linux_errno(s32 scmi_code)
 		return 0;
 
 	for (n = 0; n < ARRAY_SIZE(scmi_linux_errmap); n++)
-		if (scmi_code == scmi_linux_errmap[n].scmi)
+		if (scmi_code == scmi_linux_errmap[n].scmi) {
+			debug("errno: %s\n", scmi_linux_errmap[n].string);
 			return scmi_linux_errmap[n].errno;
+		}
 
 	return -EPROTO;
 }
-- 
2.34.1



More information about the U-Boot mailing list