[PATCH v2 3/4] platform/mellanox/mlxbf_pka: add devm_mutex_init() to initialize mutex
From: Ron Li
Date: Mon Aug 11 2025 - 12:07:43 EST
Reviewed-by: David Thompson <davthompson@xxxxxxxxxx>
Reviewed-by: Khalil Blaiech <kblaiech@xxxxxxxxxx>
Signed-off-by: Ron Li <xiangrongl@xxxxxxxxxx>
---
drivers/platform/mellanox/mlxbf_pka/mlxbf_pka_dev.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/mellanox/mlxbf_pka/mlxbf_pka_dev.c b/drivers/platform/mellanox/mlxbf_pka/mlxbf_pka_dev.c
index a0282ae0c62e..9b52d1170900 100644
--- a/drivers/platform/mellanox/mlxbf_pka/mlxbf_pka_dev.c
+++ b/drivers/platform/mellanox/mlxbf_pka/mlxbf_pka_dev.c
@@ -296,6 +296,7 @@ static int mlxbf_pka_dev_init_ring(struct device *dev,
u32 ring_mem_base;
u32 ring_mem_off;
u32 shim_ring_id;
+ int ret;
if (ring->status != MLXBF_PKA_DEV_RING_STATUS_UNDEFINED) {
dev_err(dev, "PKA ring must be undefined\n");
@@ -354,7 +355,10 @@ static int mlxbf_pka_dev_init_ring(struct device *dev,
if (!ring->ring_info)
return -ENOMEM;
- mutex_init(&ring->mutex);
+ ret = devm_mutex_init(dev, &ring->mutex);
+ if (ret)
+ return ret;
+
ring->status = MLXBF_PKA_DEV_RING_STATUS_INITIALIZED;
return 0;
@@ -1455,7 +1459,10 @@ static int mlxbf_pka_dev_init_shim(struct device *dev, struct mlxbf_pka_dev_shim
shim->trng_enabled = MLXBF_PKA_SHIM_TRNG_DISABLED;
}
- mutex_init(&shim->mutex);
+ ret = devm_mutex_init(dev, &shim->mutex);
+ if (ret)
+ return ret;
+
shim->busy_ring_num = 0;
shim->status = MLXBF_PKA_SHIM_STATUS_INITIALIZED;
--
2.43.2