From: Detlev Casanova <detlev.casanova@collabora.com>
To: u-boot@lists.denx.de, Marek Vasut <marek.vasut@mailbox.org>
Cc: Marek Vasut <marek.vasut+renesas@mailbox.org>,
Hai Pham <hai.pham.ud@renesas.com>,
Tam Nguyen <tam.nguyen.xa@renesas.com>,
Simon Glass <sjg@chromium.org>
Subject: Re: [PATCH v3 5/6] sysinfo: rcar3: Use int instead of char for revision
Date: Fri, 14 Jul 2023 14:27:28 -0400 [thread overview]
Message-ID: <2290822.ElGaqSPkdT@arisu> (raw)
In-Reply-To: <a357e25c-e30f-e6d0-949b-6a6baa9e7464@mailbox.org>
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 <detlev.casanova@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);
>
> 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.
next prev parent reply other threads:[~2023-07-14 18:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-14 16:43 [PATCH v3 0/5] Introduce the sysinfo command Detlev Casanova
2023-07-14 16:43 ` [PATCH v3 1/6] sysinfo: Add IDs for board id and revision Detlev Casanova
2023-07-14 17:26 ` Marek Vasut
2023-07-14 16:43 ` [PATCH v3 2/6] cmd: Add a sysinfo command Detlev Casanova
2023-07-14 17:29 ` Marek Vasut
2023-07-14 16:43 ` [PATCH v3 3/6] sysinfo: Add a test Detlev Casanova
2023-07-14 17:30 ` Marek Vasut
2023-07-14 16:43 ` [PATCH v3 4/6] sysinfo: Add documentation Detlev Casanova
2023-07-14 17:31 ` Marek Vasut
2023-07-17 12:27 ` Detlev Casanova
2023-07-23 22:05 ` Marek Vasut
2023-07-14 16:43 ` [PATCH v3 5/6] sysinfo: rcar3: Use int instead of char for revision Detlev Casanova
2023-07-14 17:33 ` Marek Vasut
2023-07-14 18:27 ` Detlev Casanova [this message]
2023-07-23 22:09 ` Marek Vasut
2023-07-14 16:43 ` [PATCH v3 6/6] sysinfo: rcar3: Implement BOARD_ID and BOARD_REV_* Detlev Casanova
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2290822.ElGaqSPkdT@arisu \
--to=detlev.casanova@collabora.com \
--cc=hai.pham.ud@renesas.com \
--cc=marek.vasut+renesas@mailbox.org \
--cc=marek.vasut@mailbox.org \
--cc=sjg@chromium.org \
--cc=tam.nguyen.xa@renesas.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox