diff options
author | Yann Sionneau <ysionneau@kalray.eu> | 2020-09-14 18:02:08 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-09-15 09:33:06 +0200 |
commit | f8fccf2ef8c90f2030984b2f93b21e161e2e3421 (patch) | |
tree | 0253acbcad4c4ea8f70c37b3c1e803586997ecdc /include/mci.h | |
parent | f206a2b72315b974523e80cf2ce8142b8bcc1820 (diff) | |
download | barebox-f8fccf2ef8c90f2030984b2f93b21e161e2e3421.tar.gz barebox-f8fccf2ef8c90f2030984b2f93b21e161e2e3421.tar.xz |
mci: fix wrong sd/mmc/emmc card size computation for arch where char is signed
char type can be either signed or unsigned according to C standard.
If your arch has signed char, this kind of computation will end up wrong
because of sign extension:
https://git.pengutronix.de/cgit/barebox/tree/drivers/mci/mci-core.c#n869
mci->capacity = mci->ext_csd[EXT_CSD_SEC_COUNT] << 0 |
mci->ext_csd[EXT_CSD_SEC_COUNT + 1] << 8 |
mci->ext_csd[EXT_CSD_SEC_COUNT + 2] << 16 |
mci->ext_csd[EXT_CSD_SEC_COUNT + 3] << 24;
Turning the ext_csd field into u8 * fixes the issue.
Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/mci.h')
-rw-r--r-- | include/mci.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/mci.h b/include/mci.h index b63435872b..5e6805e8dc 100644 --- a/include/mci.h +++ b/include/mci.h @@ -457,7 +457,7 @@ struct mci { uint64_t capacity; /**< Card's data capacity in bytes */ int ready_for_use; /** true if already probed */ int dsr_imp; /**< DSR implementation state from CSD */ - char *ext_csd; + u8 *ext_csd; int probe; struct param_d *param_boot; int bootpart; |