[PATCH v5 5/6] sysinfo: rcar3: Use int instead of char for revision

Detlev Casanova detlev.casanova at collabora.com
Mon Oct 2 17:20:09 CEST 2023


To be used with the sysinfo command, revision values must be considered
as integers, not chars as some boards will implement BOARD_REVISION_*
and might use numbers greater than 9.

Signed-off-by: Detlev Casanova <detlev.casanova at collabora.com>
---
 drivers/sysinfo/rcar3.c | 73 ++++++++++++++++++++++-------------------
 1 file changed, 39 insertions(+), 34 deletions(-)

diff --git a/drivers/sysinfo/rcar3.c b/drivers/sysinfo/rcar3.c
index 7b127986da7..633e80bc19b 100644
--- a/drivers/sysinfo/rcar3.c
+++ b/drivers/sysinfo/rcar3.c
@@ -68,8 +68,9 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv)
 	bool salvator_xs = false;
 	bool ebisu_4d = false;
 	bool condor_i = false;
-	char rev_major = '?';
-	char rev_minor = '?';
+	char rev[4] = "?.?";
+	u8 rev_major = 0;
+	u8 rev_minor = 0;
 
 	switch (board_id) {
 	case BOARD_SALVATOR_XS:
@@ -77,81 +78,85 @@ static void sysinfo_rcar_parse(struct sysinfo_rcar_priv *priv)
 		fallthrough;
 	case BOARD_SALVATOR_X:
 		if (!(board_rev & ~1)) { /* Only rev 0 and 1 is valid */
-			rev_major = '1';
-			rev_minor = '0' + (board_rev & BIT(0));
+			rev_major = 1;
+			rev_minor = board_rev & BIT(0);
+			snprintf(rev, sizeof(rev), "%u.%u", rev_major, rev_minor);
 		}
 		snprintf(priv->boardmodel, sizeof(priv->boardmodel),
-			 "Renesas Salvator-X%s board rev %c.%c",
-			 salvator_xs ? "S" : "", rev_major, rev_minor);
+			 "Renesas Salvator-X%s board rev %s",
+			 salvator_xs ? "S" : "", rev);
+
 		return;
 	case BOARD_STARTER_KIT:
 		if (!(board_rev & ~1)) { /* Only rev 0 and 1 is valid */
-			rev_major = (board_rev & BIT(0)) ? '3' : '1';
-			rev_minor = '0';
+			rev_major = (board_rev & BIT(0)) ? 3 : 1;
+			rev_minor = 0;
+			snprintf(rev, sizeof(rev), "%u.%u", rev_major, rev_minor);
 		}
 		snprintf(priv->boardmodel, sizeof(priv->boardmodel),
-			 "Renesas Starter Kit board rev %c.%c",
-			 rev_major, rev_minor);
+			 "Renesas Starter Kit board rev %s", rev);
 		return;
 	case BOARD_STARTER_KIT_PRE:
 		if (!(board_rev & ~3)) { /* Only rev 0..3 is valid */
-			rev_major = (board_rev & BIT(1)) ? '2' : '1';
-			rev_minor = (board_rev == 3) ? '1' : '0';
+			rev_major = (board_rev & BIT(1)) ? 2 : 1;
+			rev_minor = (board_rev == 3) ? 1 : 0;
+			snprintf(rev, sizeof(rev), "%u.%u", rev_major, rev_minor);
 		}
 		snprintf(priv->boardmodel, sizeof(priv->boardmodel),
-			 "Renesas Starter Kit Premier board rev %c.%c",
-			 rev_major, rev_minor);
+			 "Renesas Starter Kit Premier board rev %s", rev);
 		return;
 	case BOARD_EAGLE:
 		if (!board_rev) { /* Only rev 0 is valid */
-			rev_major = '1';
-			rev_minor = '0';
+			rev_major = 1;
+			rev_minor = 0;
+			snprintf(rev, sizeof(rev), "%u.%u", rev_major, rev_minor);
 		}
 		snprintf(priv->boardmodel, sizeof(priv->boardmodel),
-			 "Renesas Eagle board rev %c.%c",
-			 rev_major, rev_minor);
+			 "Renesas Eagle board rev %s", rev);
 		return;
 	case BOARD_EBISU_4D:
 		ebisu_4d = true;
 		fallthrough;
 	case BOARD_EBISU:
 		if (!board_rev) { /* Only rev 0 is valid */
-			rev_major = '1';
-			rev_minor = '0';
+			rev_major = 1;
+			rev_minor = 0;
+			snprintf(rev, sizeof(rev), "%u.%u", rev_major, rev_minor);
 		}
 		snprintf(priv->boardmodel, sizeof(priv->boardmodel),
-			 "Renesas Ebisu%s board rev %c.%c",
-			 ebisu_4d ? "-4D" : "", rev_major, rev_minor);
+			 "Renesas Ebisu%s board rev %s",
+			 ebisu_4d ? "-4D" : "", rev);
 		return;
 	case BOARD_DRAAK:
 		if (!board_rev) { /* Only rev 0 is valid */
-			rev_major = '1';
-			rev_minor = '0';
+			rev_major = 1;
+			rev_minor = 0;
+			snprintf(rev, sizeof(rev), "%u.%u", rev_major, rev_minor);
 		}
 		snprintf(priv->boardmodel, sizeof(priv->boardmodel),
-			 "Renesas Draak board rev %c.%c",
-			 rev_major, rev_minor);
+			 "Renesas Draak board rev %s", rev);
 		return;
 	case BOARD_KRIEK:
 		if (!board_rev) { /* Only rev 0 is valid */
-			rev_major = '1';
-			rev_minor = '0';
+			rev_major = 1;
+			rev_minor = 0;
+			snprintf(rev, sizeof(rev), "%u.%u", rev_major, rev_minor);
 		}
 		snprintf(priv->boardmodel, sizeof(priv->boardmodel),
-			 "Renesas Kriek board rev %c.%c",
-			 rev_major, rev_minor);
+			 "Renesas Kriek board rev %s", rev);
 		return;
 	case BOARD_CONDOR_I:
 		condor_i = true;
 		fallthrough;
 	case BOARD_CONDOR:
 		if (!board_rev) { /* Only rev 0 is valid */
-			rev_major = '1';
-			rev_minor = '0';
+			rev_major = 1;
+			rev_minor = 0;
+			snprintf(rev, sizeof(rev), "%u.%u", rev_major, rev_minor);
 		}
 		snprintf(priv->boardmodel, sizeof(priv->boardmodel),
-			"Renesas Condor%s board rev %c.%c",
-			condor_i ? "-I" : "", rev_major, rev_minor);
+			 "Renesas Condor%s board rev %s",
+			 condor_i ? "-I" : "", rev);
 		return;
 	default:
 		snprintf(priv->boardmodel, sizeof(priv->boardmodel),
-- 
2.41.0



More information about the U-Boot mailing list