flash/stm32l4x: introduce flash programming without loader
[openocd.git] / src / flash / nor / tcl.c
index 1705384c7acbd0cad1769c4cc4f835276d821f08..cbc64dcc40e0c36f23eacbc7afbacc3aa11ec6f6 100644 (file)
@@ -88,7 +88,7 @@ COMMAND_HANDLER(handle_flash_info_command)
        if (retval != ERROR_OK)
                return retval;
 
-       if (p != NULL) {
+       if (p) {
                int num_blocks;
                struct flash_sector *block_array;
 
@@ -99,7 +99,7 @@ COMMAND_HANDLER(handle_flash_info_command)
 
                /* If the driver does not implement protection, we show the default
                 * state of is_protected array - usually protection state unknown */
-               if (p->driver->protect_check == NULL) {
+               if (!p->driver->protect_check) {
                        retval = ERROR_FLASH_OPER_UNSUPPORTED;
                } else {
                        /* We must query the hardware to avoid printing stale information! */
@@ -148,7 +148,7 @@ COMMAND_HANDLER(handle_flash_info_command)
                                protect_state);
                }
 
-               if (p->driver->info != NULL) {
+               if (p->driver->info) {
                        /* Let the flash driver print extra custom info */
                        retval = p->driver->info(p, CMD);
                        command_print_sameline(CMD, "\n");
@@ -584,7 +584,7 @@ COMMAND_HANDLER(handle_flash_fill_command)
        uint32_t padding_at_end = aligned_end - end_addr;
 
        uint8_t *buffer = malloc(aligned_size);
-       if (buffer == NULL)
+       if (!buffer)
                return ERROR_FAIL;
 
        if (padding_at_start) {
@@ -724,7 +724,7 @@ COMMAND_HANDLER(handle_flash_md_command)
        }
 
        uint8_t *buffer = calloc(count, wordsize);
-       if (buffer == NULL) {
+       if (!buffer) {
                command_print(CMD, "No memory for flash read buffer");
                return ERROR_FAIL;
        }
@@ -799,7 +799,7 @@ COMMAND_HANDLER(handle_flash_write_bank_command)
        uint32_t padding_at_end = aligned_end - end_addr;
 
        buffer = malloc(aligned_size);
-       if (buffer == NULL) {
+       if (!buffer) {
                fileio_close(fileio);
                LOG_ERROR("Out of memory");
                return ERROR_FAIL;
@@ -896,7 +896,7 @@ COMMAND_HANDLER(handle_flash_read_bank_command)
        }
 
        buffer = malloc(length);
-       if (buffer == NULL) {
+       if (!buffer) {
                LOG_ERROR("Out of memory");
                return ERROR_FAIL;
        }
@@ -990,7 +990,7 @@ COMMAND_HANDLER(handle_flash_verify_bank_command)
                        "first %zu bytes of the file", length);
 
        buffer_file = malloc(length);
-       if (buffer_file == NULL) {
+       if (!buffer_file) {
                LOG_ERROR("Out of memory");
                fileio_close(fileio);
                return ERROR_FAIL;
@@ -1011,7 +1011,7 @@ COMMAND_HANDLER(handle_flash_verify_bank_command)
        }
 
        buffer_flash = malloc(length);
-       if (buffer_flash == NULL) {
+       if (!buffer_flash) {
                LOG_ERROR("Out of memory");
                free(buffer_file);
                return ERROR_FAIL;
@@ -1262,28 +1262,28 @@ COMMAND_HANDLER(handle_flash_bank_command)
        CMD_ARGC--;
 
        struct target *target = get_target(CMD_ARGV[5]);
-       if (target == NULL) {
+       if (!target) {
                LOG_ERROR("target '%s' not defined", CMD_ARGV[5]);
                return ERROR_FAIL;
        }
 
        const char *driver_name = CMD_ARGV[0];
        const struct flash_driver *driver = flash_driver_find_by_name(driver_name);
-       if (NULL == driver) {
+       if (!driver) {
                /* no matching flash driver found */
                LOG_ERROR("flash driver '%s' not found", driver_name);
                return ERROR_FAIL;
        }
 
        /* check the flash bank name is unique */
-       if (get_flash_bank_by_name_noprobe(bank_name) != NULL) {
+       if (get_flash_bank_by_name_noprobe(bank_name)) {
                /* flash bank name already exists  */
                LOG_ERROR("flash bank name '%s' already exists", bank_name);
                return ERROR_FAIL;
        }
 
        /* register flash specific commands */
-       if (NULL != driver->commands) {
+       if (driver->commands) {
                int retval = register_commands(CMD_CTX, NULL,
                                driver->commands);
                if (retval != ERROR_OK) {
@@ -1313,7 +1313,7 @@ COMMAND_HANDLER(handle_flash_bank_command)
                return retval;
        }
 
-       if (driver->usage == NULL)
+       if (!driver->usage)
                LOG_DEBUG("'%s' driver usage field missing", driver_name);
 
        flash_bank_add(c);

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)