mirror of https://github.com/ARMmbed/mbed-os.git
removing output parameter from avoid_conflict_nvstore_tdbstore function.
parent
fcd24aa62b
commit
677dbd1612
|
@ -953,7 +953,6 @@ int TDBStore::init()
|
|||
uint32_t actual_data_size;
|
||||
int os_ret, ret = MBED_SUCCESS, reserved_ret;
|
||||
uint16_t versions[_num_areas];
|
||||
internal_mem_resident_type_e out_in_mem_res;
|
||||
|
||||
_mutex.lock();
|
||||
|
||||
|
@ -962,8 +961,8 @@ int TDBStore::init()
|
|||
}
|
||||
|
||||
//Check if we are on internal memory && try to set the internal memory for TDBStore use.
|
||||
if (strcmp(_bd->get_type(), "FLASHIAP")==0 &&
|
||||
set_internal_storage_ownership(TDBSTORE, &out_in_mem_res) == MBED_ERROR_ALREADY_INITIALIZED) {
|
||||
if (strcmp(_bd->get_type(), "FLASHIAP") == 0 &&
|
||||
avoid_conflict_nvstore_tdbstore(TDBSTORE) == MBED_ERROR_ALREADY_INITIALIZED) {
|
||||
|
||||
MBED_ERROR(MBED_ERROR_ALREADY_INITIALIZED, "TDBStore in internal memory can not be initialize when NVStore is in use");
|
||||
}
|
||||
|
|
|
@ -851,14 +851,13 @@ int NVStore::init()
|
|||
uint16_t keys[NVSTORE_NUM_AREAS];
|
||||
uint16_t actual_size;
|
||||
uint8_t owner;
|
||||
internal_mem_resident_type_e out_in_mem_res;
|
||||
|
||||
if (_init_done) {
|
||||
return NVSTORE_SUCCESS;
|
||||
}
|
||||
|
||||
//Check if we are on internal memory && try to set the internal memory for TDBStore use.
|
||||
ret = set_internal_storage_ownership(NVSTORE, &out_in_mem_res);
|
||||
ret = avoid_conflict_nvstore_tdbstore(NVSTORE);
|
||||
//NVstore in internal memory can not be initialize when TDBStore is in use
|
||||
MBED_ASSERT(ret != MBED_ERROR_ALREADY_INITIALIZED);
|
||||
|
||||
|
|
|
@ -43,27 +43,27 @@
|
|||
|
||||
using namespace mbed;
|
||||
|
||||
static internal_mem_resident_type_e internal_memory_residency = NONE;
|
||||
static SingletonPtr<PlatformMutex> system_storage_mutex;
|
||||
|
||||
MBED_WEAK int set_internal_storage_ownership(internal_mem_resident_type_e in_mem_res, internal_mem_resident_type_e *out_mem_res)
|
||||
|
||||
MBED_WEAK int avoid_conflict_nvstore_tdbstore(owner_type_e in_mem_owner)
|
||||
{
|
||||
int status = MBED_SUCCESS;
|
||||
static PlatformMutex _mutex;
|
||||
static owner_type_e internal_memory_owner = NONE;
|
||||
|
||||
system_storage_mutex->lock();
|
||||
_mutex.lock();
|
||||
|
||||
if (internal_memory_residency != NONE &&
|
||||
internal_memory_residency != in_mem_res) {
|
||||
if (internal_memory_owner != NONE &&
|
||||
internal_memory_owner != in_mem_owner) {
|
||||
|
||||
status = MBED_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
} else {
|
||||
|
||||
internal_memory_residency = in_mem_res;
|
||||
internal_memory_owner = in_mem_owner;
|
||||
}
|
||||
|
||||
*out_mem_res = internal_memory_residency;
|
||||
system_storage_mutex->unlock();
|
||||
_mutex.unlock();
|
||||
|
||||
return status;
|
||||
}
|
||||
|
|
|
@ -22,16 +22,15 @@ typedef enum {
|
|||
NONE = 0,
|
||||
NVSTORE,
|
||||
TDBSTORE
|
||||
} internal_mem_resident_type_e;
|
||||
} owner_type_e;
|
||||
|
||||
/**
|
||||
* @brief Try to get an ownership for the internal flash memory storage type.
|
||||
* KVSTORE or NVSTORE is the current option and once the ownership is taken by one
|
||||
* second one can not be initialize.
|
||||
* @param[in] in_mem_res Enum parameter to specify NVSTORE or KVSTORE as the storage owner
|
||||
* @param[in] out_mem_res Enum parameter which specify who is the current owner of the storage.
|
||||
* @param[in] in_mem_owner Enum parameter to specify NVSTORE or KVSTORE as the storage owner
|
||||
* @returns MBED_SUCCESS if succeeded or MBED_ERROR_ALREADY_INITIALIZED if fails.
|
||||
*/
|
||||
int set_internal_storage_ownership(internal_mem_resident_type_e in_mem_res, internal_mem_resident_type_e *out_mem_res);
|
||||
int avoid_conflict_nvstore_tdbstore(owner_type_e in_mem_owner);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue