Skip to contentSkip to conversation

mci: Print versions with micro levels correctly

PATCH Applied Trent Piepho 2 participants 2 messages Nov 4, 2015 – Nov 5, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mci: Print versions with micro levels correctly

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.

---
 drivers/mci/mci-core.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/mci/mci-core.c +4 -5
index 9000115..29c0d54 100644
@@ -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;
 }
Signature · 7 lines
1.8.3.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#1 lore raw
Quoted 6 lines · Trent Piepho

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.

Applied, thanks

Sascha

Quoted 36 lines
---
 drivers/mci/mci-core.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/mci/mci-core.c +4 -5
index 9000115..29c0d54 100644
@@ -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;
 }
Signature · 7 lines
1.8.3.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox