From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AA51FC001DC for ; Fri, 14 Jul 2023 18:27:31 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 41EB184735; Fri, 14 Jul 2023 20:27:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="W3WFVJbu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D8C988469F; Fri, 14 Jul 2023 20:27:27 +0200 (CEST) Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BCD7E84735 for ; Fri, 14 Jul 2023 20:27:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=detlev.casanova@collabora.com Received: from arisu.localnet (unknown [23.233.251.139]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: detlev) by madras.collabora.co.uk (Postfix) with ESMTPSA id 9BD3A660702E; Fri, 14 Jul 2023 19:27:24 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1689359245; bh=yauViCzqp6ui0OHWI50Gi+nYZ8zOlQBVtDO1d4Y5jWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W3WFVJbuBW3D0jKhv1hfRxb2TiQWkbE3ZjpVHR4KHIhPvpmzfEyx7trwAP9pF3KOB NpWKoH9y2yQWnhK8zctn85UGV7OJMj2HEDXJqo4otitr3oJTEOnLdu77dittTqRbqL xsBIv61RtnwBFHdT7fmdklOPD15Ufh/Fp4+ubd0MPK3f78vG0m6RL4AaJ9vC6NZvZ+ GklV5BmYZb9UZbmuN7HiDpZN5MaR5a1W1UGCe1PUBwuUfYD6Q6RFDthcpHzFcFosKZ QRpMKKbzuLp2QROK+8VDF06ulO35uKikO4PSgCcQZRyEYVmAjAILD6Q2uzVBK47biv hG5cKvLwIV/UA== From: Detlev Casanova To: u-boot@lists.denx.de, Marek Vasut Cc: Marek Vasut , Hai Pham , Tam Nguyen , Simon Glass Subject: Re: [PATCH v3 5/6] sysinfo: rcar3: Use int instead of char for revision Date: Fri, 14 Jul 2023 14:27:28 -0400 Message-ID: <2290822.ElGaqSPkdT@arisu> In-Reply-To: References: <20230714164424.838842-1-detlev.casanova@collabora.com> <20230714164424.838842-6-detlev.casanova@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean On Friday, July 14, 2023 1:33:01 P.M. EDT Marek Vasut wrote: > On 7/14/23 18:43, Detlev Casanova wrote: > > 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 > > --- > > > > 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); > > Is there really no way to do this with single snprintf() call instead of > two snprintf() calls ? I find it more readable like this, as opposed to have an snprintf in the if and one in an else block for each switch case.