You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2026/05/11 09:54:34 UTC
(mynewt-core) 02/04: stm32/hash: Allow multiply open
This is an automated email from the ASF dual-hosted git repository.
kasjer pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 5c86e299bf0fc9922e80c7d3c4d5296b3f055ba7
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Mon May 11 07:42:54 2026 +0200
stm32/hash: Allow multiply open
HASH peripheral usage is guarded by mutex, this
is enough allow for os_dev to be open several
times.
Additionally HASH peripheral clock is enabled in
stm32_hash_start instead of dev_open and disabled
in stm32_hasl_finish (it was never disabled)
This removes _ret versions completly leaving
new styl names that return int values.
Signed-off-by: Jerzy Kasenberg <je...@codecoup.pl>
---
hw/drivers/hash/hash_stm32/src/hash_stm32.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/hw/drivers/hash/hash_stm32/src/hash_stm32.c b/hw/drivers/hash/hash_stm32/src/hash_stm32.c
index 68c2b3789..30058eaa0 100644
--- a/hw/drivers/hash/hash_stm32/src/hash_stm32.c
+++ b/hw/drivers/hash/hash_stm32/src/hash_stm32.c
@@ -45,8 +45,6 @@ stm32_hash_start(struct hash_dev *hash, void *ctx, uint16_t algo)
return -1;
}
- os_mutex_pend(&gmtx, OS_TIMEOUT_NEVER);
-
switch (algo) {
case HASH_ALGO_SHA224:
algomask = HASH_ALGOSELECTION_SHA224;
@@ -59,6 +57,10 @@ stm32_hash_start(struct hash_dev *hash, void *ctx, uint16_t algo)
return -1;
}
+ os_mutex_pend(&gmtx, OS_TIMEOUT_NEVER);
+
+ __HAL_RCC_HASH_CLK_ENABLE();
+
((struct hash_sha2_context *)ctx)->remain = 0;
HASH->CR = algomask | HASH_CR_INIT | HASH_DATATYPE_8B;
@@ -150,6 +152,8 @@ stm32_hash_finish(struct hash_dev *hash, void *ctx, uint16_t algo,
u32p[i] = os_bswap_32(HASH_DIGEST->HR[i]);
}
+ __HAL_RCC_HASH_CLK_DISABLE();
+
os_mutex_release(&gmtx);
return 0;
}
@@ -162,13 +166,10 @@ stm32_hash_dev_open(struct os_dev *dev, uint32_t wait, void *arg)
hash = (struct hash_dev *)dev;
assert(hash);
- /* XXX Not reentrant? */
- if (dev->od_flags & OS_DEV_F_STATUS_OPEN) {
- return OS_EBUSY;
+ if ((dev->od_flags & OS_DEV_F_STATUS_READY) == 0) {
+ return OS_ERROR;
}
- __HAL_RCC_HASH_CLK_ENABLE();
-
return 0;
}