Skip to content

Commit

Permalink
[Silabs] Move NVM semaphore creation to nvm3_lockBegin() (#26270)
Browse files Browse the repository at this point in the history
* Move NVM initialization to sl_platform_init() in matter_support submodule

Also move nvm3_Sem creation to nvm3_lockBegin()

* Restore the call to nvm3_open(), it's safe to call multiple times
  • Loading branch information
selissia authored and pull[bot] committed Nov 14, 2023
1 parent 5edcd4b commit 1006896
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 7 additions & 8 deletions src/platform/silabs/SilabsConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ static StaticSemaphore_t nvm3_SemStruct;

void nvm3_lockBegin(void)
{
if (nvm3_Sem == NULL)
{
nvm3_Sem = xSemaphoreCreateBinaryStatic(&nvm3_SemStruct);
xSemaphoreGive(nvm3_Sem);
}

VerifyOrDie(nvm3_Sem != NULL);
xSemaphoreTake(nvm3_Sem, portMAX_DELAY);
}
Expand All @@ -65,15 +71,8 @@ namespace Internal {

CHIP_ERROR SilabsConfig::Init()
{
#ifndef BRD4325A // TODO: fix semaphore usage in nvm3_lock for siwx917. use weak implementation for that board instead
nvm3_Sem = xSemaphoreCreateBinaryStatic(&nvm3_SemStruct);
// nvm3_Sem is created in nvm3_lockBegin()

if (nvm3_Sem == NULL)
{
return CHIP_ERROR_NO_MEMORY;
}
xSemaphoreGive(nvm3_Sem);
#endif // not BRD4325A
return MapNvm3Error(nvm3_open(nvm3_defaultHandle, nvm3_defaultInit));
}

Expand Down

0 comments on commit 1006896

Please sign in to comment.