File tree Expand file tree Collapse file tree 4 files changed +15
-18
lines changed Expand file tree Collapse file tree 4 files changed +15
-18
lines changed Original file line number Diff line number Diff line change @@ -953,7 +953,6 @@ int TDBStore::init()
953
953
uint32_t actual_data_size;
954
954
int os_ret, ret = MBED_SUCCESS, reserved_ret;
955
955
uint16_t versions[_num_areas];
956
- internal_mem_resident_type_e out_in_mem_res;
957
956
958
957
_mutex.lock ();
959
958
@@ -962,8 +961,8 @@ int TDBStore::init()
962
961
}
963
962
964
963
// Check if we are on internal memory && try to set the internal memory for TDBStore use.
965
- if (strcmp (_bd->get_type (), " FLASHIAP" )== 0 &&
966
- set_internal_storage_ownership (TDBSTORE, &out_in_mem_res ) == MBED_ERROR_ALREADY_INITIALIZED) {
964
+ if (strcmp (_bd->get_type (), " FLASHIAP" ) == 0 &&
965
+ avoid_conflict_nvstore_tdbstore (TDBSTORE) == MBED_ERROR_ALREADY_INITIALIZED) {
967
966
968
967
MBED_ERROR (MBED_ERROR_ALREADY_INITIALIZED, " TDBStore in internal memory can not be initialize when NVStore is in use" );
969
968
}
Original file line number Diff line number Diff line change @@ -851,14 +851,13 @@ int NVStore::init()
851
851
uint16_t keys[NVSTORE_NUM_AREAS];
852
852
uint16_t actual_size;
853
853
uint8_t owner;
854
- internal_mem_resident_type_e out_in_mem_res;
855
854
856
855
if (_init_done) {
857
856
return NVSTORE_SUCCESS;
858
857
}
859
858
860
859
// Check if we are on internal memory && try to set the internal memory for TDBStore use.
861
- ret = set_internal_storage_ownership (NVSTORE, &out_in_mem_res );
860
+ ret = avoid_conflict_nvstore_tdbstore (NVSTORE);
862
861
// NVstore in internal memory can not be initialize when TDBStore is in use
863
862
MBED_ASSERT (ret != MBED_ERROR_ALREADY_INITIALIZED);
864
863
Original file line number Diff line number Diff line change 43
43
44
44
using namespace mbed ;
45
45
46
- static internal_mem_resident_type_e internal_memory_residency = NONE;
47
- static SingletonPtr<PlatformMutex> system_storage_mutex;
48
46
49
- MBED_WEAK int set_internal_storage_ownership (internal_mem_resident_type_e in_mem_res, internal_mem_resident_type_e *out_mem_res)
47
+
48
+ MBED_WEAK int avoid_conflict_nvstore_tdbstore (owner_type_e in_mem_owner)
50
49
{
51
50
int status = MBED_SUCCESS;
51
+ static PlatformMutex _mutex;
52
+ static owner_type_e internal_memory_owner = NONE;
52
53
53
- system_storage_mutex-> lock ();
54
+ _mutex. lock ();
54
55
55
- if (internal_memory_residency != NONE &&
56
- internal_memory_residency != in_mem_res ) {
56
+ if (internal_memory_owner != NONE &&
57
+ internal_memory_owner != in_mem_owner ) {
57
58
58
59
status = MBED_ERROR_ALREADY_INITIALIZED;
59
60
60
61
} else {
61
62
62
- internal_memory_residency = in_mem_res ;
63
+ internal_memory_owner = in_mem_owner ;
63
64
}
64
65
65
- *out_mem_res = internal_memory_residency;
66
- system_storage_mutex->unlock ();
66
+ _mutex.unlock ();
67
67
68
68
return status;
69
69
}
Original file line number Diff line number Diff line change @@ -22,16 +22,15 @@ typedef enum {
22
22
NONE = 0 ,
23
23
NVSTORE ,
24
24
TDBSTORE
25
- } internal_mem_resident_type_e ;
25
+ } owner_type_e ;
26
26
27
27
/**
28
28
* @brief Try to get an ownership for the internal flash memory storage type.
29
29
* KVSTORE or NVSTORE is the current option and once the ownership is taken by one
30
30
* second one can not be initialize.
31
- * @param[in] in_mem_res Enum parameter to specify NVSTORE or KVSTORE as the storage owner
32
- * @param[in] out_mem_res Enum parameter which specify who is the current owner of the storage.
31
+ * @param[in] in_mem_owner Enum parameter to specify NVSTORE or KVSTORE as the storage owner
33
32
* @returns MBED_SUCCESS if succeeded or MBED_ERROR_ALREADY_INITIALIZED if fails.
34
33
*/
35
- int set_internal_storage_ownership ( internal_mem_resident_type_e in_mem_res , internal_mem_resident_type_e * out_mem_res );
34
+ int avoid_conflict_nvstore_tdbstore ( owner_type_e in_mem_owner );
36
35
37
36
#endif
You can’t perform that action at this time.
0 commit comments