lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250723102515.64585-2-tarang.raval@siliconsignals.io>
Date: Wed, 23 Jul 2025 15:55:05 +0530
From: Tarang Raval <tarang.raval@...iconsignals.io>
To: sakari.ailus@...ux.intel.com,
	laurent.pinchart@...asonboard.com,
	hverkuil@...all.nl
Cc: Tarang Raval <tarang.raval@...iconsignals.io>,
	Mauro Carvalho Chehab <mchehab@...nel.org>,
	Ricardo Ribalda <ribalda@...omium.org>,
	Yunke Cao <yunkec@...gle.com>,
	Hans de Goede <hansg@...nel.org>,
	James Cowgill <james.cowgill@...ize.com>,
	Tomi Valkeinen <tomi.valkeinen@...asonboard.com>,
	Lad Prabhakar <prabhakar.mahadev-lad.rj@...renesas.com>,
	Tommaso Merciai <tomm.merciai@...il.com>,
	linux-media@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [PATCH 1/4] media: mc: Add devm_media_entity_pads_init() helper

Add a devm-managed version of media_entity_pads_init() to simplify
pad initialization and cleanup using devres.

Signed-off-by: Tarang Raval <tarang.raval@...iconsignals.io>
---
 drivers/media/mc/mc-entity.c | 19 +++++++++++++++++++
 include/media/media-entity.h | 20 ++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c
index 045590905582..fe50da3faf08 100644
--- a/drivers/media/mc/mc-entity.c
+++ b/drivers/media/mc/mc-entity.c
@@ -8,6 +8,7 @@
  *	     Sakari Ailus <sakari.ailus@....fi>
  */
 
+#include <linux/device/devres.h>
 #include <linux/bitmap.h>
 #include <linux/list.h>
 #include <linux/property.h>
@@ -235,6 +236,24 @@ int media_entity_pads_init(struct media_entity *entity, u16 num_pads,
 }
 EXPORT_SYMBOL_GPL(media_entity_pads_init);
 
+static void devm_media_entity_cleanup(void *data)
+{
+	media_entity_cleanup(data);
+}
+
+int devm_media_entity_pads_init(struct device *dev, struct media_entity *entity,
+				u16 num_pads, struct media_pad *pads)
+{
+	int err;
+
+	err = media_entity_pads_init(entity, num_pads, pads);
+	if (err)
+		return err;
+
+	return devm_add_action_or_reset(dev, devm_media_entity_cleanup, entity);
+}
+EXPORT_SYMBOL_GPL(devm_media_entity_pads_init);
+
 /* -----------------------------------------------------------------------------
  * Graph traversal
  */
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 64cf590b1134..28b904fe34ae 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -717,6 +717,26 @@ void media_gobj_destroy(struct media_gobj *gobj);
 int media_entity_pads_init(struct media_entity *entity, u16 num_pads,
 		      struct media_pad *pads);
 
+/**
+ * devm_media_entity_pads_init - Managed initialization of media entity pads
+ *
+ * @dev:        Device that manages the lifecycle of the media entity.
+ * @entity:     Entity where the pads belong.
+ * @num_pads:   Total number of sink and source pads.
+ * @pads:       Array of @num_pads pads.
+ *
+ * This function initializes the pads for the given media entity and registers
+ * a managed cleanup action to be performed automatically when the device is
+ * detached or the driver is unloaded.
+ *
+ * This is a managed version of media_entity_pads_init(), and simplifies resource
+ * management using devres.
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+int devm_media_entity_pads_init(struct device *dev, struct media_entity *entity,
+				u16 num_pads, struct media_pad *pads);
+
 /**
  * media_entity_cleanup() - free resources associated with an entity
  *
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ