Thread (89 messages) 89 messages, 9 authors, 2017-05-30

[RFC v3 16/21] media: Add release callback for media device

From: Sakari Ailus <sakari.ailus@linux.intel.com>
Date: 2016-08-26 23:44:47
Subsystem: media controller framework, media input infrastructure (v4l/dvb), the rest · Maintainers: Sakari Ailus, Laurent Pinchart, Mauro Carvalho Chehab, Linus Torvalds

The release callback may be used by the driver to signal the release of
the media device. This way the lifetime of the driver's own memory
allocations may be made dependent on that of the media device.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/media/media-device.c | 4 ++++
 include/media/media-device.h | 1 +
 2 files changed, 5 insertions(+)
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index 5698823..82ae07a 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -726,6 +726,10 @@ static void media_device_release(struct media_devnode *devnode)
 	mdev->entity_internal_idx_max = 0;
 	media_entity_graph_walk_cleanup(&mdev->pm_count_walk);
 	mutex_destroy(&mdev->graph_mutex);
+
+	if (mdev->release)
+		mdev->release(mdev);
+
 	put_device(mdev->dev);
 
 	kfree(mdev);
diff --git a/include/media/media-device.h b/include/media/media-device.h
index 9728d8a..310640a 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -152,6 +152,7 @@ struct media_device {
 
 	int (*link_notify)(struct media_link *link, u32 flags,
 			   unsigned int notification);
+	void (*release)(struct media_device *mdev);
 };
 
 /* We don't need to include pci.h or usb.h here */
-- 
2.1.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help