Skip to content

Commit 07222ae

Browse files
author
nils
committed
addres lock release API comment
1 parent 14c7551 commit 07222ae

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/rp2_common/pico_mbedtls/pico_mbedtls.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ void mbedtls_sha256_init(__unused mbedtls_sha256_context *ctx) {
3636
}
3737

3838
void mbedtls_sha256_free(__unused mbedtls_sha256_context *ctx) {
39-
if (ctx->locked) {
40-
pico_sha256_unlock(ctx);
41-
}
39+
pico_sha256_cleanup(ctx);
4240
}
4341

4442
int mbedtls_sha256_starts_ret(mbedtls_sha256_context *ctx, int is224) {

src/rp2_common/pico_sha256/include/pico/sha256.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ typedef struct pico_sha256_state {
5858
size_t total_data_size;
5959
} pico_sha256_state_t;
6060

61-
/*! \brief Release the internal lock on the SHA256 hardware
61+
/*! \brief Release the internal lock on the SHA-256 hardware
6262
* \ingroup pico_sha256
6363
*
64-
* Release the internal lock on the hardware.
64+
* Release the internal lock on the SHA-256 hardware.
6565
* Fails if the internal lock was not claimed.
6666
*
6767
* @param state A pointer to a pico_sha256_state_t instance
6868
*/
69-
void __weak pico_sha256_unlock(pico_sha256_state_t *state);
69+
void pico_sha256_cleanup(pico_sha256_state_t *state);
7070

7171
/*! \brief Start a SHA-256 calculation returning immediately with an error if the SHA-256 hardware is not available
7272
* \ingroup pico_sha256

src/rp2_common/pico_sha256/sha256.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ void __weak pico_sha256_unlock(pico_sha256_state_t *state) {
3030
state->locked = false;
3131
}
3232

33+
void pico_sha256_cleanup(pico_sha256_state_t *state) {
34+
if (state->locked) {
35+
pico_sha256_unlock(state);
36+
}
37+
}
38+
3339
int pico_sha256_try_start(pico_sha256_state_t *state, enum sha256_endianness endianness, bool use_dma) {
3440
memset(state, 0, sizeof(*state));
3541
if (!pico_sha256_lock(state)) return PICO_ERROR_RESOURCE_IN_USE;

0 commit comments

Comments
 (0)