This is an automated email from the ASF dual-hosted git repository.

m-gorecki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 743fcf3c5c9aea707dc828707627d91d4dbf88f0
Author: Michal Gorecki <[email protected]>
AuthorDate: Fri Sep 4 13:33:43 2026 +0200

    hw/drivers/crypto: Rename crypto_nrf52 to crypto_nrf
    
    Rename to more generic name, as driver can be also used
    with nrf53 devices with minimal changes.
---
 .../include/crypto_nrf/crypto_nrf.h}               |  8 ++---
 .../crypto/{crypto_nrf52 => crypto_nrf}/pkg.yml    |  4 +--
 .../crypto_nrf52.c => crypto_nrf/src/crypto_nrf.c} | 34 +++++++++++-----------
 .../crypto/{crypto_nrf52 => crypto_nrf}/syscfg.yml |  0
 hw/mcu/nordic/nrf52xxx/pkg.yml                     |  2 +-
 hw/mcu/nordic/nrf52xxx/src/nrf52_periph.c          |  7 ++---
 6 files changed, 27 insertions(+), 28 deletions(-)

diff --git a/hw/drivers/crypto/crypto_nrf52/include/crypto_nrf52/crypto_nrf52.h 
b/hw/drivers/crypto/crypto_nrf/include/crypto_nrf/crypto_nrf.h
similarity index 86%
rename from hw/drivers/crypto/crypto_nrf52/include/crypto_nrf52/crypto_nrf52.h
rename to hw/drivers/crypto/crypto_nrf/include/crypto_nrf/crypto_nrf.h
index f9c574d8a..6e97211be 100644
--- a/hw/drivers/crypto/crypto_nrf52/include/crypto_nrf52/crypto_nrf52.h
+++ b/hw/drivers/crypto/crypto_nrf/include/crypto_nrf/crypto_nrf.h
@@ -17,8 +17,8 @@
  * under the License.
  */
 
-#ifndef __CRYPTO_NRF52_H__
-#define __CRYPTO_NRF52_H__
+#ifndef __CRYPTO_NRF_H__
+#define __CRYPTO_NRF_H__
 
 #include "crypto/crypto.h"
 
@@ -26,10 +26,10 @@
 extern "C" {
 #endif
 
-int nrf52_crypto_dev_init(struct os_dev *dev, void *arg);
+int nrf_crypto_dev_init(struct os_dev *dev, void *arg);
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif /* __CRYPTO_NRF52_H__ */
+#endif /* __CRYPTO_NRF_H__ */
diff --git a/hw/drivers/crypto/crypto_nrf52/pkg.yml 
b/hw/drivers/crypto/crypto_nrf/pkg.yml
similarity index 91%
rename from hw/drivers/crypto/crypto_nrf52/pkg.yml
rename to hw/drivers/crypto/crypto_nrf/pkg.yml
index c4bb1c553..bc9451d86 100644
--- a/hw/drivers/crypto/crypto_nrf52/pkg.yml
+++ b/hw/drivers/crypto/crypto_nrf/pkg.yml
@@ -17,8 +17,8 @@
 # under the License.
 #
 
-pkg.name: hw/drivers/crypto/crypto_nrf52
-pkg.description: Crypto driver for nRF52xxx
+pkg.name: hw/drivers/crypto/crypto_nrf
+pkg.description: Crypto driver for nRF5x devices
 pkg.author: "Apache Mynewt <[email protected]>"
 pkg.homepage: "http://mynewt.apache.org/";
 pkg.keywords:
diff --git a/hw/drivers/crypto/crypto_nrf52/src/crypto_nrf52.c 
b/hw/drivers/crypto/crypto_nrf/src/crypto_nrf.c
similarity index 75%
rename from hw/drivers/crypto/crypto_nrf52/src/crypto_nrf52.c
rename to hw/drivers/crypto/crypto_nrf/src/crypto_nrf.c
index 276d8fa01..d18f1db1f 100644
--- a/hw/drivers/crypto/crypto_nrf52/src/crypto_nrf52.c
+++ b/hw/drivers/crypto/crypto_nrf/src/crypto_nrf.c
@@ -21,7 +21,7 @@
 #include "mcu/cmsis_nvic.h"
 #include <os/mynewt.h>
 #include "crypto/crypto.h"
-#include "crypto_nrf52/crypto_nrf52.h"
+#include "crypto_nrf/crypto_nrf.h"
 
 static struct os_mutex gmtx;
 
@@ -32,7 +32,7 @@ struct aes_128_data {
 };
 
 static bool
-nrf52_crypto_ecb_start(const struct aes_128_data *crypto_data)
+nrf_crypto_ecb_start(const struct aes_128_data *crypto_data)
 {
     bool rc;
     uint32_t end;
@@ -67,8 +67,8 @@ nrf52_crypto_ecb_start(const struct aes_128_data *crypto_data)
 }
 
 static uint32_t
-nrf52_crypto_encrypt_ecb(struct crypto_dev *crypto, const uint8_t *key,
-        const uint8_t *inbuf, uint8_t *outbuf, size_t len)
+nrf_crypto_encrypt_ecb(struct crypto_dev *crypto, const uint8_t *key,
+                       const uint8_t *inbuf, uint8_t *outbuf, size_t len)
 {
     struct aes_128_data crypto_data;
     uint32_t i;
@@ -89,7 +89,7 @@ nrf52_crypto_encrypt_ecb(struct crypto_dev *crypto, const 
uint8_t *key,
 
         memcpy(crypto_data.plain, &inbuf[i], len);
 
-        while (nrf52_crypto_ecb_start(&crypto_data) == false) {
+        while (nrf_crypto_ecb_start(&crypto_data) == false) {
             /*
              * If this fails it means that the AES engine was used causing the
              * operation to abort. Just try again as the upper layer code does
@@ -113,8 +113,8 @@ nrf52_crypto_encrypt_ecb(struct crypto_dev *crypto, const 
uint8_t *key,
 }
 
 static bool
-nrf52_crypto_has_support(struct crypto_dev *crypto, uint8_t op, uint16_t algo,
-        uint16_t mode, uint16_t keylen)
+nrf_crypto_has_support(struct crypto_dev *crypto, uint8_t op, uint16_t algo,
+                       uint16_t mode, uint16_t keylen)
 {
     (void)crypto;
 
@@ -127,21 +127,21 @@ nrf52_crypto_has_support(struct crypto_dev *crypto, 
uint8_t op, uint16_t algo,
 }
 
 static uint32_t
-nrf52_crypto_encrypt(struct crypto_dev *crypto, uint16_t algo, uint16_t mode,
-        const uint8_t *key, uint16_t keylen, uint8_t *iv, const uint8_t *inbuf,
-        uint8_t *outbuf, uint32_t len)
+nrf_crypto_encrypt(struct crypto_dev *crypto, uint16_t algo, uint16_t mode,
+                   const uint8_t *key, uint16_t keylen, uint8_t *iv,
+                   const uint8_t *inbuf, uint8_t *outbuf, uint32_t len)
 {
     (void)iv;
 
-    if (!nrf52_crypto_has_support(crypto, CRYPTO_OP_ENCRYPT, algo, mode, 
keylen)) {
+    if (!nrf_crypto_has_support(crypto, CRYPTO_OP_ENCRYPT, algo, mode, 
keylen)) {
         return 0;
     }
 
-    return nrf52_crypto_encrypt_ecb(crypto, key, inbuf, outbuf, len);
+    return nrf_crypto_encrypt_ecb(crypto, key, inbuf, outbuf, len);
 }
 
 static int
-nrf52_crypto_dev_open(struct os_dev *dev, uint32_t wait, void *arg)
+nrf_crypto_dev_open(struct os_dev *dev, uint32_t wait, void *arg)
 {
     struct crypto_dev *crypto;
 
@@ -156,20 +156,20 @@ nrf52_crypto_dev_open(struct os_dev *dev, uint32_t wait, 
void *arg)
 }
 
 int
-nrf52_crypto_dev_init(struct os_dev *dev, void *arg)
+nrf_crypto_dev_init(struct os_dev *dev, void *arg)
 {
     struct crypto_dev *crypto;
 
     crypto = (struct crypto_dev *)dev;
     assert(crypto);
 
-    OS_DEV_SETHANDLERS(dev, nrf52_crypto_dev_open, NULL);
+    OS_DEV_SETHANDLERS(dev, nrf_crypto_dev_open, NULL);
 
     assert(os_mutex_init(&gmtx) == 0);
 
-    crypto->interface.encrypt = nrf52_crypto_encrypt;
+    crypto->interface.encrypt = nrf_crypto_encrypt;
     crypto->interface.decrypt = NULL;
-    crypto->interface.has_support = nrf52_crypto_has_support;
+    crypto->interface.has_support = nrf_crypto_has_support;
 
     return 0;
 }
diff --git a/hw/drivers/crypto/crypto_nrf52/syscfg.yml 
b/hw/drivers/crypto/crypto_nrf/syscfg.yml
similarity index 100%
rename from hw/drivers/crypto/crypto_nrf52/syscfg.yml
rename to hw/drivers/crypto/crypto_nrf/syscfg.yml
diff --git a/hw/mcu/nordic/nrf52xxx/pkg.yml b/hw/mcu/nordic/nrf52xxx/pkg.yml
index 1c4a43af0..5ad62468e 100644
--- a/hw/mcu/nordic/nrf52xxx/pkg.yml
+++ b/hw/mcu/nordic/nrf52xxx/pkg.yml
@@ -63,7 +63,7 @@ pkg.deps.TRNG:
     - "@apache-mynewt-core/hw/drivers/trng/trng_nrf52"
 
 pkg.deps.CRYPTO:
-    - "@apache-mynewt-core/hw/drivers/crypto/crypto_nrf52"
+    - "@apache-mynewt-core/hw/drivers/crypto/crypto_nrf"
 
 pkg.deps.UART_0:
     - "@apache-mynewt-core/hw/drivers/uart/uart_hal"
diff --git a/hw/mcu/nordic/nrf52xxx/src/nrf52_periph.c 
b/hw/mcu/nordic/nrf52xxx/src/nrf52_periph.c
index f3413ca27..5ef846cdc 100644
--- a/hw/mcu/nordic/nrf52xxx/src/nrf52_periph.c
+++ b/hw/mcu/nordic/nrf52xxx/src/nrf52_periph.c
@@ -52,7 +52,7 @@
 #endif
 #if MYNEWT_VAL(CRYPTO)
 #include "crypto/crypto.h"
-#include "crypto_nrf52/crypto_nrf52.h"
+#include "crypto_nrf/crypto_nrf.h"
 #endif
 #if MYNEWT_VAL(UART_0) || MYNEWT_VAL(UART_1)
 #include "uart/uart.h"
@@ -353,9 +353,8 @@ nrf52_periph_create_crypto(void)
     (void)rc;
 
 #if MYNEWT_VAL(CRYPTO)
-    rc = os_dev_create(&os_bsp_crypto.dev, "crypto",
-                       OS_DEV_INIT_PRIMARY, OS_DEV_INIT_PRIO_DEFAULT,
-                       nrf52_crypto_dev_init, NULL);
+    rc = os_dev_create(&os_bsp_crypto.dev, "crypto", OS_DEV_INIT_PRIMARY,
+                       OS_DEV_INIT_PRIO_DEFAULT, nrf_crypto_dev_init, NULL);
     assert(rc == 0);
 #endif
 }

Reply via email to