mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Trent Piepho <tpiepho@kymetacorp.com>
Cc: "barebox@lists.infradead.org" <barebox@lists.infradead.org>
Subject: Re: [PATCH] mci: Fix version numbers again
Date: Tue, 7 Jun 2016 08:07:23 +0200	[thread overview]
Message-ID: <20160607060723.GC31666@pengutronix.de> (raw)
In-Reply-To: <1464724743.15779.113.camel@rtred1test09.kymeta.local>

On Tue, May 31, 2016 at 07:58:56PM +0000, Trent Piepho wrote:
> The SD and eMMC version numbers are a pain to print and sort, since
> they are inconsistent in if a two digit minor version shdoulde be
> treated as a single number or as minor and micro version numbers.
> 
> This allows version 1.10 and 4.5 and 4.41, where 41 is less than 5.
> 
> Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
> ---

Applied, thanks

Sascha

>  drivers/mci/mci-core.c | 14 +++++++++-----
>  include/mci.h          |  7 ++++++-
>  2 files changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
> index 59f6675..42dde06 100644
> --- a/drivers/mci/mci-core.c
> +++ b/drivers/mci/mci-core.c
> @@ -949,14 +949,18 @@ out:
>  
>  static char *mci_version_string(struct mci *mci)
>  {
> -	static char version[sizeof("x.xx")];
> -	unsigned major, minor;
> +	static char version[sizeof("xx.xxx")];
> +	unsigned major, minor, micro;
> +	int n;
>  
>  	major = (mci->version >> 8) & 0xf;
> -	minor = mci->version & 0xff;
> +	minor = (mci->version >> 4) & 0xf;
> +	micro = mci->version & 0xf;
>  
> -	/* Shift off last digit of minor if it's 0 */
> -	sprintf(version, "%u.%x", major, minor & 0xf ? minor : minor >> 4);
> +	n = sprintf(version, "%u.%u", major, minor);
> +	/* Omit zero micro versions */
> +	if (micro)
> +		sprintf(version + n, "%u", micro);
>  
>  	return version;
>  }
> diff --git a/include/mci.h b/include/mci.h
> index 174d150..001c86c 100644
> --- a/include/mci.h
> +++ b/include/mci.h
> @@ -30,11 +30,16 @@
>  #include <block.h>
>  #include <regulator.h>
>  
> +/* These codes should be sorted numerically in order of newness.  If the last
> + * nybble is a zero, it will not be printed.  So 0x120 -> "1.2" and 0x123 ->
> + * "1.23", 0x1a0 -> "1.10", 0x1b0 and 0x111 -> "1.11" but sort differently.
> + * It's not possible to create "1.20".  */
> +
>  /* Firmware revisions for SD cards */
>  #define SD_VERSION_SD		0x20000
> -#define SD_VERSION_2		(SD_VERSION_SD | 0x200)
>  #define SD_VERSION_1_0		(SD_VERSION_SD | 0x100)
>  #define SD_VERSION_1_10		(SD_VERSION_SD | 0x1a0)
> +#define SD_VERSION_2		(SD_VERSION_SD | 0x200)
>  
>  /* Firmware revisions for MMC cards */
>  #define MMC_VERSION_MMC		0x10000
> -- 
> 2.7.0.25.gfc10eb5.dirty
> 
> 

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

      reply	other threads:[~2016-06-07  6:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-30  9:01 MCI print revision Alexander Shiyan
2016-05-31  6:26 ` Sascha Hauer
2016-05-31  7:02   ` Re[2]: " Alexander Shiyan
2016-05-31  7:23     ` Sascha Hauer
2016-05-31  7:33       ` Re[2]: " Alexander Shiyan
2016-05-31 19:56       ` Trent Piepho
2016-05-31 19:58         ` [PATCH] mci: Fix version numbers again Trent Piepho
2016-06-07  6:07           ` Sascha Hauer [this message]

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=20160607060723.GC31666@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=tpiepho@kymetacorp.com \
    /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