From 2f2e3a7e7c3c14466e552d5f7e2e8b41739bdfc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= Date: Thu, 23 Mar 2017 11:25:20 -0700 Subject: [PATCH] modules: dataman: ram_flash: No need to write/erase data that do not need to persist Just update in RAM is enough. --- src/modules/dataman/dataman.c | 47 ++++------------------------------- 1 file changed, 5 insertions(+), 42 deletions(-) diff --git a/src/modules/dataman/dataman.c b/src/modules/dataman/dataman.c index 8909e5ec15..694cbbb14c 100644 --- a/src/modules/dataman/dataman.c +++ b/src/modules/dataman/dataman.c @@ -569,7 +569,10 @@ _ram_flash_write(dm_item_t item, unsigned index, dm_persitence_t persistence, co return ret; } - _ram_flash_update_flush_timeout(); + if (persistence == DM_PERSIST_POWER_ON_RESET) { + _ram_flash_update_flush_timeout(); + } + return ret; } #endif @@ -883,47 +886,7 @@ _file_restart(dm_reset_reason reason) static int _ram_flash_restart(dm_reset_reason reason) { - uint8_t *buffer = dm_operations_data.ram.data; - bool need_flush = false; - - /* We need to scan the entire file and invalidate and data that should not persist after the last reset */ - - /* Loop through all of the data segments and delete those that are not persistent */ - - for (dm_item_t item = DM_KEY_SAFE_POINTS; item < DM_KEY_NUM_KEYS; item++) { - for (unsigned i = 0; i < g_per_item_max_index[item]; i++) { - /* check if segment contains data */ - if (buffer[0]) { - bool clear_entry = false; - - /* Whether data gets deleted depends on reset type and data segment's persistence setting */ - if (reason == DM_INIT_REASON_POWER_ON) { - if (buffer[1] > DM_PERSIST_POWER_ON_RESET) { - clear_entry = true; - } - - } else { - if (buffer[1] > DM_PERSIST_IN_FLIGHT_RESET) { - clear_entry = true; - } - } - - /* Set segment to unused if data does not persist */ - if (clear_entry) { - buffer[0] = 0; - need_flush = true; - } - } - - buffer += g_per_item_size[item]; - } - } - - if (need_flush) { - _ram_flash_update_flush_timeout(); - } - - return 0; + return dm_ram_operations.restart(reason); } #endif