Skip to content

Commit f62997f

Browse files
committed
drivers: nrf_mram: check for mram_latency service returns
When requesting/releasing the no_latency mode for the mram, verify that the request/release is successful to avoid running into infinite loop if the mram controller is in autopowerdown mode. Signed-off-by: Riadh Ghaddab <riadh.ghaddab@nordicsemi.no>
1 parent 46162b2 commit f62997f

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

drivers/flash/soc_flash_nrf_mram.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,11 @@ static int nrf_mram_write(const struct device *dev, off_t offset, const void *da
297297

298298
if (ironside_se_ver >= IRONSIDE_SE_SUPPORT_READY_VER) {
299299
#if defined(CONFIG_MRAM_LATENCY)
300-
mram_no_latency_sync_request();
300+
ret = mram_no_latency_sync_request();
301+
if (ret) {
302+
LOG_ERR("Failed to request no-latency mode for MRAM write");
303+
goto unlock;
304+
}
301305
#endif
302306
}
303307

@@ -346,7 +350,11 @@ static int nrf_mram_write(const struct device *dev, off_t offset, const void *da
346350
#endif
347351
if (ironside_se_ver >= IRONSIDE_SE_SUPPORT_READY_VER) {
348352
#if defined(CONFIG_MRAM_LATENCY)
349-
mram_no_latency_sync_release();
353+
ret = mram_no_latency_sync_release();
354+
if (ret) {
355+
LOG_ERR("Failed to release no-latency mode for MRAM write");
356+
goto unlock;
357+
}
350358
#endif
351359
}
352360

@@ -374,7 +382,11 @@ static int nrf_mram_erase(const struct device *dev, off_t offset, size_t size)
374382
/* Ensure that the mramc banks are powered on */
375383
if (ironside_se_ver >= IRONSIDE_SE_SUPPORT_READY_VER) {
376384
#if defined(CONFIG_MRAM_LATENCY)
377-
mram_no_latency_sync_request();
385+
ret = mram_no_latency_sync_request();
386+
if (ret) {
387+
LOG_ERR("Failed to request no-latency mode for MRAM erase");
388+
goto unlock;
389+
}
378390
#endif
379391
}
380392

@@ -421,7 +433,11 @@ static int nrf_mram_erase(const struct device *dev, off_t offset, size_t size)
421433

422434
if (ironside_se_ver >= IRONSIDE_SE_SUPPORT_READY_VER) {
423435
#if defined(CONFIG_MRAM_LATENCY)
424-
mram_no_latency_sync_release();
436+
ret = mram_no_latency_sync_release();
437+
if (ret) {
438+
LOG_ERR("Failed to release no-latency mode for MRAM erase");
439+
goto unlock;
440+
}
425441
#endif
426442
}
427443

0 commit comments

Comments
 (0)