From 61ddbd35207af8dbd9b1a0c17619148179235203 Mon Sep 17 00:00:00 2001 From: Yegor Yefremov Date: Wed, 25 May 2016 09:51:13 +0200 Subject: crypto: add CRC32 digest CRC32 digest can be used to check CRC32 hashes in FIT images etc. Signed-off-by: Yegor Yefremov Signed-off-by: Sascha Hauer --- include/crypto/crc.h | 16 ++++++++++++++++ include/digest.h | 1 + 2 files changed, 17 insertions(+) create mode 100644 include/crypto/crc.h (limited to 'include') diff --git a/include/crypto/crc.h b/include/crypto/crc.h new file mode 100644 index 0000000000..6428634d0a --- /dev/null +++ b/include/crypto/crc.h @@ -0,0 +1,16 @@ +/* + * Common values for CRC algorithms + */ + +#ifndef _CRYPTO_CRC_H +#define _CRYPTO_CRC_H + +#include + +#define CRC32_DIGEST_SIZE 4 + +struct crc32_state { + ulong crc; +}; + +#endif diff --git a/include/digest.h b/include/digest.h index fe30cc27e0..4552e58255 100644 --- a/include/digest.h +++ b/include/digest.h @@ -41,6 +41,7 @@ enum hash_algo { HASH_ALGO_TGR_128, HASH_ALGO_TGR_160, HASH_ALGO_TGR_192, + HASH_ALGO_CRC32, HASH_ALGO__LAST }; -- cgit v1.2.3 From edb96cf3d72920d428cef39a80dffb131d67e696 Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Tue, 31 May 2016 19:58:56 +0000 Subject: mci: Fix version numbers again 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 Signed-off-by: Sascha Hauer --- drivers/mci/mci-core.c | 14 +++++++++----- include/mci.h | 7 ++++++- 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c index 59f66757d9..42dde06c3c 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 174d15022a..0370547b0f 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 -- cgit v1.2.3