[PATCH] media: iris: use devm_mutex_init()

Bartosz Golaszewski posted 1 patch 1 month, 2 weeks ago
drivers/media/platform/qcom/iris/iris_probe.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
[PATCH] media: iris: use devm_mutex_init()
Posted by Bartosz Golaszewski 1 month, 2 weeks ago
Drop the call to mutex_destroy() in .remove() by using the managed API
in .probe().

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/media/platform/qcom/iris/iris_probe.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/qcom/iris/iris_probe.c b/drivers/media/platform/qcom/iris/iris_probe.c
index 9bc9b34c2576..0a4e7595a16e 100644
--- a/drivers/media/platform/qcom/iris/iris_probe.c
+++ b/drivers/media/platform/qcom/iris/iris_probe.c
@@ -202,8 +202,6 @@ static void iris_remove(struct platform_device *pdev)
 	video_unregister_device(core->vdev_enc);
 
 	v4l2_device_unregister(&core->v4l2_dev);
-
-	mutex_destroy(&core->lock);
 }
 
 static void iris_sys_error_handler(struct work_struct *work)
@@ -228,9 +226,12 @@ static int iris_probe(struct platform_device *pdev)
 	core->dev = dev;
 
 	core->state = IRIS_CORE_DEINIT;
-	mutex_init(&core->lock);
 	init_completion(&core->core_init_done);
 
+	ret = devm_mutex_init(core->dev, &core->lock);
+	if (ret)
+		return ret;
+
 	core->response_packet = devm_kzalloc(core->dev, IFACEQ_CORE_PKT_SIZE, GFP_KERNEL);
 	if (!core->response_packet)
 		return -ENOMEM;
-- 
2.47.3
Re: [PATCH] media: iris: use devm_mutex_init()
Posted by Johan Hovold 1 month, 2 weeks ago
On Tue, Dec 23, 2025 at 11:25:28AM +0100, Bartosz Golaszewski wrote:
> Drop the call to mutex_destroy() in .remove() by using the managed API
> in .probe().

You commit message should explain *why* you think this should be done.

mutex_destroy() doesn't free anything and is just used for a pretty
useless debugging feature. And devres is not free and increases runtime
memory consumption.

And you're also adding more lines than you are removing.

Johan