From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail.kymetacorp.com ([192.81.58.21]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zu4Gs-0002ru-4O for barebox@lists.infradead.org; Wed, 04 Nov 2015 20:03:02 +0000 From: Trent Piepho Date: Wed, 4 Nov 2015 20:02:36 +0000 Message-ID: <1446667356.4553.1.camel@rtred1test09.kymeta.local> Content-Language: en-US Content-ID: MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH] mci: Print versions with micro levels correctly To: barebox 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 --- 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