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 @@ 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..0370547 100644 --- a/include/mci.h +++ b/include/mci.h @@ -30,11 +30,16 @@ #include #include +/* 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