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

Detlev Casanova detlev.casanova at collabora.com
Thu Jul 20 16:49:46 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 | 104 ++++++++++++++++++++++++----------------
 1 file changed, 62 insertions(+), 42 deletions(-)

diff --git a/drivers/sysinfo/rcar3.c b/drivers/sysinfo/rcar3.c
index 7b127986da7..450a4c26773 100644
--- a/drivers/sysinfo/rcar3.c
+++ b/drivers/sysinfo/rcar3.c
@@ -68,90 +68,110 @@ 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 model[64];
+	char rev[4] = "?.?";
+	u8 rev_major = 0;
+	u8 rev_minor = 0;
 
 	switch (board_id) {
 	case BOARD_SALVATOR_XS:
 		salvator_xs = true;
 		fallthrough;
 	case BOARD_SALVATOR_X:
+		snprintf(model, sizeof(model),
+			 "Renesas Salvator-X%s board", salvator_xs ? "S" : "");
 		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);
+
+		snprintf(priv->boardmodel, sizeof(priv->boardmodel), "%s rev %s",
+			 model, rev);
+
 		return;
 	case BOARD_STARTER_KIT:
+		snprintf(priv->boardmodel, sizeof(priv->boardmodel),
+			 "Renesas Starter Kit board");
 		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);
+		snprintf(priv->boardmodel, sizeof(priv->boardmodel), "%s rev %s",
+			 model, rev);
 		return;
 	case BOARD_STARTER_KIT_PRE:
+		snprintf(priv->boardmodel, sizeof(priv->boardmodel),
+			 "Renesas Starter Kit Premier board");
 		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);
+		snprintf(priv->boardmodel, sizeof(priv->boardmodel), "%s rev %s",
+			 model, rev);
 		return;
 	case BOARD_EAGLE:
+		snprintf(priv->boardmodel, sizeof(priv->boardmodel),
+			 "Renesas Eagle board");
 		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);
+		snprintf(priv->boardmodel, sizeof(priv->boardmodel), "%s rev %s",
+			 model, rev);
 		return;
 	case BOARD_EBISU_4D:
 		ebisu_4d = true;
 		fallthrough;
 	case BOARD_EBISU:
+		snprintf(priv->boardmodel, sizeof(priv->boardmodel),
+			 "Renesas Ebisu%s board", ebisu_4d ? "-4D" : "");
 		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);
+		snprintf(priv->boardmodel, sizeof(priv->boardmodel), "%s rev %s",
+			 model, rev);
 		return;
 	case BOARD_DRAAK:
+		snprintf(priv->boardmodel, sizeof(priv->boardmodel),
+			 "Renesas Draak board");
 		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);
+		snprintf(priv->boardmodel, sizeof(priv->boardmodel), "%s rev %s",
+			 model, rev);
 		return;
 	case BOARD_KRIEK:
+		snprintf(priv->boardmodel, sizeof(priv->boardmodel),
+			 "Renesas Kriek board");
 		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);
+		snprintf(priv->boardmodel, sizeof(priv->boardmodel), "%s rev %s",
+			 model, rev);
 		return;
 	case BOARD_CONDOR_I:
 		condor_i = true;
 		fallthrough;
 	case BOARD_CONDOR:
+		snprintf(priv->boardmodel, sizeof(priv->boardmodel),
+			 "Renesas Condor%s board", condor_i ? "-I" : "");
 		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);
+		snprintf(priv->boardmodel, sizeof(priv->boardmodel), "%s rev %s",
+			 model, rev);
 		return;
 	default:
 		snprintf(priv->boardmodel, sizeof(priv->boardmodel),
-- 
2.41.0



More information about the U-Boot mailing list