This is an automated email from Gerrit.

"Jérôme Pouiller <[email protected]>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9445

-- gerrit

commit 6c7f33cb40ec04ffc0bdfbac08f5ce88bdd74150
Author: Jérôme Pouiller <[email protected]>
Date:   Tue Feb 3 13:37:21 2026 +0100

    flash/nor/efm32: Avoid declaration after statements
    
    While this is not enforced checkpatch, I prefer to avoid to declare
    variable on the top of scope rather than in the middle of the code.
    
    This is also the opportunity to apply "reverse Christmas tree" declaration
    order.
    
    Signed-off-by: Jérôme Pouiller <[email protected]>
    Change-Id: I07469887df88c0a9912e730a8bb052c16058de98

diff --git a/src/flash/nor/efm32.c b/src/flash/nor/efm32.c
index 9ece92d1d0..9208ec2d79 100644
--- a/src/flash/nor/efm32.c
+++ b/src/flash/nor/efm32.c
@@ -328,11 +328,13 @@ static int efm32_read_info(struct flash_bank *bank)
 FLASH_BANK_COMMAND_HANDLER(efm32_flash_bank_command)
 {
        struct efm32_flash_chip *efm32_info = NULL;
+       struct flash_bank *bank_iter;
+       int bank_index;
 
        if (CMD_ARGC < 6)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
-       int bank_index = efm32_get_bank_index(bank->base);
+       bank_index = efm32_get_bank_index(bank->base);
        if (bank_index < 0) {
                LOG_ERROR("Flash bank with base address %" PRIx32 " is not 
supported",
                        (uint32_t)bank->base);
@@ -340,7 +342,7 @@ FLASH_BANK_COMMAND_HANDLER(efm32_flash_bank_command)
        }
 
        /* look for an existing flash structure matching target */
-       for (struct flash_bank *bank_iter = flash_bank_list(); bank_iter; 
bank_iter = bank_iter->next) {
+       for (bank_iter = flash_bank_list(); bank_iter; bank_iter = 
bank_iter->next) {
                if (bank_iter->driver == &efm32_flash
                        && bank_iter->target == bank->target
                        && bank->driver_priv) {
@@ -619,12 +621,12 @@ static int efm32_write_only_lockbits(struct flash_bank 
*bank)
 static int efm32_write_lock_data(struct flash_bank *bank)
 {
        struct efm32_flash_chip *efm32_info = bank->driver_priv;
+       uint32_t extra_bytes = efm32_info->info.page_size - LOCKWORDS_SZ;
+       uint8_t *extra_data = NULL;
        int ret = 0;
 
        /* Preserve any data written to the high portion of the lockbits page */
        assert(efm32_info->info.page_size >= LOCKWORDS_SZ);
-       uint32_t extra_bytes = efm32_info->info.page_size - LOCKWORDS_SZ;
-       uint8_t *extra_data = NULL;
 
        if (extra_bytes) {
                extra_data = malloc(extra_bytes);
@@ -687,17 +689,14 @@ static int efm32_get_page_lock(struct flash_bank *bank, 
size_t page)
 static int efm32_set_page_lock(struct flash_bank *bank, size_t page, int set)
 {
        struct efm32_flash_chip *efm32_info = bank->driver_priv;
+       uint32_t *dw = &efm32_info->lb_page[page >> 5];
+       uint32_t mask = BIT(page & 0x1f);
 
        if (bank->base != EFM32_FLASH_BASE) {
                LOG_ERROR("Locking user and lockbits pages is not supported 
yet");
                return ERROR_FAIL;
        }
 
-       uint32_t *dw = &efm32_info->lb_page[page >> 5];
-       uint32_t mask = 0;
-
-       mask = BIT(page & 0x1f);
-
        if (!set)
                *dw |= mask;
        else
@@ -1155,18 +1154,20 @@ static int efm32_get_info(struct flash_bank *bank, 
struct command_invocation *cm
 
 COMMAND_HANDLER(efm32_handle_debuglock_command)
 {
-       struct target *target = NULL;
+       struct efm32_flash_chip *efm32_info;
+       struct flash_bank *bank;
+       struct target *target;
+       uint32_t *ptr;
+       int ret;
 
        if (CMD_ARGC < 1)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
-       struct flash_bank *bank;
-       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
-       if (retval != ERROR_OK)
-               return retval;
-
-       struct efm32_flash_chip *efm32_info = bank->driver_priv;
+       ret = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
+       if (ret != ERROR_OK)
+               return ret;
 
+       efm32_info = bank->driver_priv;
        target = bank->target;
 
        if (target->state != TARGET_HALTED) {
@@ -1174,14 +1175,13 @@ COMMAND_HANDLER(efm32_handle_debuglock_command)
                return ERROR_TARGET_NOT_HALTED;
        }
 
-       uint32_t *ptr;
        ptr = efm32_info->lb_page + 127;
        *ptr = 0;
 
-       retval = efm32_write_lock_data(bank);
-       if (retval != ERROR_OK) {
+       ret = efm32_write_lock_data(bank);
+       if (ret != ERROR_OK) {
                LOG_ERROR("Failed to write LB page");
-               return retval;
+               return ret;
        }
 
        command_print(CMD, "efm32 debug interface locked, reset the device to 
apply");

-- 

Reply via email to