diff options
author | Tarek BOCHKATI <tarek.bouchkati@gmail.com> | 2020-03-22 19:36:12 +0100 |
---|---|---|
committer | Tomas Vanek <vanekt@fbl.cz> | 2020-11-15 21:55:39 +0000 |
commit | 726b0c592884566a7580780418ba763ffc51c745 (patch) | |
tree | 7d0d1489fa5e3d9d2c61d47b805fcbe98a039f49 | |
parent | 3d736e0488bc498358e3d49d7ce728b17955c8fe (diff) | |
download | riscv-openocd-726b0c592884566a7580780418ba763ffc51c745.zip riscv-openocd-726b0c592884566a7580780418ba763ffc51c745.tar.gz riscv-openocd-726b0c592884566a7580780418ba763ffc51c745.tar.bz2 |
stm32l4x: cosmetic simplification of get_stm32l4_info
Change-Id: I2542f946f64388d908b1502f869643080fce9f9e
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5536
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Andreas Bolsch <hyphen0break@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
-rw-r--r-- | src/flash/nor/stm32l4x.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/flash/nor/stm32l4x.c b/src/flash/nor/stm32l4x.c index 2bf2913..55a8d8f 100644 --- a/src/flash/nor/stm32l4x.c +++ b/src/flash/nor/stm32l4x.c @@ -1218,19 +1218,17 @@ static int get_stm32l4_info(struct flash_bank *bank, char *buf, int buf_size) for (unsigned int i = 0; i < part_info->num_revs; i++) { if (rev_id == part_info->revs[i].rev) { rev_str = part_info->revs[i].str; - - if (rev_str != NULL) { - snprintf(buf, buf_size, "%s - Rev: %s%s", - part_info->device_str, rev_str, stm32l4_info->probed ? - (stm32l4_info->dual_bank_mode ? " dual-bank" : " single-bank") : ""); - return ERROR_OK; - } + break; } } - snprintf(buf, buf_size, "%s - Rev: unknown (0x%04x)%s", - part_info->device_str, rev_id, stm32l4_info->probed ? - (stm32l4_info->dual_bank_mode ? " dual-bank" : " single-bank") : ""); + int buf_len = snprintf(buf, buf_size, "%s - Rev %s : 0x%04x", + part_info->device_str, rev_str ? rev_str : "'unknown'", rev_id); + + if (stm32l4_info->probed) + snprintf(buf + buf_len, buf_size - buf_len, " - %s-bank", + stm32l4_info->dual_bank_mode ? "Flash dual" : "Flash single"); + return ERROR_OK; } else { snprintf(buf, buf_size, "Cannot identify target as an %s device", device_families); |