Skip to content

Commit bd6cc1f

Browse files
de-nordicMaureenHelm
authored andcommitted
drivers/flash/nrf_qspi_nor: Modify qspi_erase loop condition
The commit removes an error check from the erase loop and instead add breaks in places where errors that would break an execution of the loop occur. Signed-off-by: Dominik Ermel <[email protected]>
1 parent eac10ef commit bd6cc1f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

drivers/flash/nrf_qspi_nor.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,11 @@ static int qspi_erase(const struct device *dev, uint32_t addr, uint32_t size)
431431
}
432432
qspi_trans_lock(dev);
433433
rv = qspi_nor_write_protection_set(dev, false);
434+
if (rv != 0) {
435+
goto out_trans_unlock;
436+
}
434437
qspi_lock(dev);
435-
while ((rv == 0) && (size > 0)) {
438+
while (size > 0) {
436439
nrfx_err_t res = !NRFX_SUCCESS;
437440
uint32_t adj = 0;
438441

@@ -453,7 +456,7 @@ static int qspi_erase(const struct device *dev, uint32_t addr, uint32_t size)
453456
} else {
454457
/* minimal erase size is at least a sector size */
455458
LOG_ERR("unsupported at 0x%lx size %zu", (long)addr, size);
456-
rv = -EINVAL;
459+
res = NRFX_ERROR_INVALID_PARAM;
457460
}
458461

459462
qspi_wait_for_completion(dev, res);
@@ -463,18 +466,20 @@ static int qspi_erase(const struct device *dev, uint32_t addr, uint32_t size)
463466
} else {
464467
LOG_ERR("erase error at 0x%lx size %zu", (long)addr, size);
465468
rv = qspi_get_zephyr_ret_code(res);
469+
break;
466470
}
467471
}
468472
qspi_unlock(dev);
469473

470474
int rv2 = qspi_nor_write_protection_set(dev, true);
471475

472-
qspi_trans_unlock(dev);
473-
474476
if (!rv) {
475477
rv = rv2;
476478
}
477479

480+
out_trans_unlock:
481+
qspi_trans_unlock(dev);
482+
478483
out:
479484
ANOMALY_122_UNINIT(dev);
480485
return rv;

0 commit comments

Comments
 (0)