Skip to contentSkip to conversation

media: iris: use devm_mutex_init()

PATCH In review Bartosz Golaszewski 2 participants 2 messages Dec 23, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: iris: use devm_mutex_init()

Drop the call to mutex_destroy() in .remove() by using the managed API in .probe().

---
 drivers/media/platform/qcom/iris/iris_probe.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/media/platform/qcom/iris/iris_probe.c +4 -3
index 9bc9b34c2576..0a4e7595a16e 100644
@@ -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;
Signature · 1 line
2.47.3
#1 lore raw
Quoted 2 lines · Bartosz Golaszewski

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