mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] mci: Print versions with micro levels correctly
@ 2015-11-04 20:02 Trent Piepho
  2015-11-05  8:01 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Trent Piepho @ 2015-11-04 20:02 UTC (permalink / raw)
  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 <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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] mci: Print versions with micro levels correctly
  2015-11-04 20:02 [PATCH] mci: Print versions with micro levels correctly Trent Piepho
@ 2015-11-05  8:01 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2015-11-05  8:01 UTC (permalink / raw)
  To: Trent Piepho; +Cc: barebox

On Wed, Nov 04, 2015 at 08:02:36PM +0000, Trent Piepho wrote:
> 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>

Applied, thanks

Sascha

> ---
>  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
> 

-- 
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-11-05  8:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-04 20:02 [PATCH] mci: Print versions with micro levels correctly Trent Piepho
2015-11-05  8:01 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox