mirror of https://github.com/ARMmbed/mbed-os.git
Address concurrency and style issues
1. Use atomic operations to increase and decrease counter. 2. Style fixes. Remove unused function declaration.pull/7099/head
parent
479438953f
commit
1f5cee967d
|
@ -36,7 +36,6 @@ typedef struct {
|
|||
mbedtls_platform_context;
|
||||
|
||||
|
||||
void mbedtls_platform_init( mbedtls_platform_context* ctx);
|
||||
/**
|
||||
* \brief This function performs any platform initialization operations,
|
||||
* needed for setting up cryptographic modules.
|
||||
|
|
|
@ -20,13 +20,15 @@
|
|||
|
||||
#include "mbedtls/platform.h"
|
||||
#if defined(MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT)
|
||||
mbedtls_platform_context ctx = {0};
|
||||
#include "mbed_critical.h"
|
||||
|
||||
mbedtls_platform_context ctx = { };
|
||||
|
||||
int mbedtls_platform_setup( mbedtls_platform_context *obsolete_ctx )
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ctx.reference_count++;
|
||||
core_util_atomic_incr_u32( ( volatile uint32_t * )&ctx.reference_count, 1 );
|
||||
|
||||
if( ctx.reference_count == 1 )
|
||||
{
|
||||
|
@ -39,8 +41,7 @@ int mbedtls_platform_setup( mbedtls_platform_context *obsolete_ctx )
|
|||
void mbedtls_platform_teardown( mbedtls_platform_context *obsolete_ctx )
|
||||
{
|
||||
|
||||
ctx.reference_count--;
|
||||
|
||||
core_util_atomic_decr_u32( ( volatile uint32_t * )&ctx.reference_count, 1 );
|
||||
if( ctx.reference_count <= 0 )
|
||||
{
|
||||
/* call platform specific code to terminate crypto driver */
|
||||
|
|
Loading…
Reference in New Issue