stm32l4x: cosmetic simplification of get_stm32l4_info 36/5536/6
authorTarek BOCHKATI <tarek.bouchkati@gmail.com>
Sun, 22 Mar 2020 18:36:12 +0000 (19:36 +0100)
committerTomas Vanek <vanekt@fbl.cz>
Sun, 15 Nov 2020 21:55:39 +0000 (21:55 +0000)
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>
src/flash/nor/stm32l4x.c

index 2bf291368cc12687441d7cfaf8e5e71ab818e8e6..55a8d8ff3a50f341d5df1f18121e8677011f3dff 100644 (file)
@@ -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);

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)