From: Trent Piepho <tpiepho@kymetacorp.com>
To: barebox <barebox@lists.infradead.org>
Subject: [PATCH] mci: Print versions with micro levels correctly
Date: Wed, 4 Nov 2015 20:02:36 +0000 [thread overview]
Message-ID: <1446667356.4553.1.camel@rtred1test09.kymeta.local> (raw)
The version is stored as BCD, e.g. 0x40 -> ".4" and 0x41 -> ".41".
The latter was getting printed as ".65". Simplify the logic a bit to
not split the minor into nybbles just to re-assemble it into a byte
again.
Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
---
drivers/mci/mci-core.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 9000115..29c0d54 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -947,14 +947,13 @@ out:
static char *mci_version_string(struct mci *mci)
{
static char version[sizeof("x.xx")];
- unsigned major, minor, micro;
+ unsigned major, minor;
major = (mci->version >> 8) & 0xf;
- minor = (mci->version >> 4) & 0xf;
- micro = mci->version & 0xf;
+ minor = mci->version & 0xff;
- sprintf(version, "%u.%u", major,
- micro ? (minor << 4) | micro : minor);
+ /* Shift off last digit of minor if it's 0 */
+ sprintf(version, "%u.%x", major, minor & 0xf ? minor : minor >> 4);
return version;
}
--
1.8.3.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next reply other threads:[~2015-11-04 20:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-04 20:02 Trent Piepho [this message]
2015-11-05 8:01 ` Sascha Hauer
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=1446667356.4553.1.camel@rtred1test09.kymeta.local \
--to=tpiepho@kymetacorp.com \
--cc=barebox@lists.infradead.org \
/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