summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2019-02-21 08:37:42 -0500
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2019-03-19 13:24:28 -0400
commit0e43734d4c46e156785bb1d2acc5b3c10b7d5dd5 (patch)
tree803de4b1d91f85ebe8ab9153bdad7a26f7a1c1b4 /include
parentea6c7e34f3b28e165988aa7391310752969842e8 (diff)
media: v4l2-subdev: add release() internal op
If the subdevice created a device node, then the v4l2_subdev cannot be freed until the last user of the device node closes it. This means that we need a release() callback in v4l2_subdev_internal_ops that is called from the video_device release function so the subdevice driver can postpone freeing memory until the that callback is called. If no video device node was created then the release callback can be called immediately when the subdev is unregistered. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/media/v4l2-subdev.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 349e1c18cf48..e807aa96ed3b 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -755,7 +755,17 @@ struct v4l2_subdev_ops {
*
* @open: called when the subdev device node is opened by an application.
*
- * @close: called when the subdev device node is closed.
+ * @close: called when the subdev device node is closed. Please note that
+ * it is possible for @close to be called after @unregistered!
+ *
+ * @release: called when the last user of the subdev device is gone. This
+ * happens after the @unregistered callback and when the last open
+ * filehandle to the v4l-subdevX device node was closed. If no device
+ * node was created for this sub-device, then the @release callback
+ * is called right after the @unregistered callback.
+ * The @release callback is typically used to free the memory containing
+ * the v4l2_subdev structure. It is almost certainly required for any
+ * sub-device that sets the V4L2_SUBDEV_FL_HAS_DEVNODE flag.
*
* .. note::
* Never call this from drivers, only the v4l2 framework can call
@@ -766,6 +776,7 @@ struct v4l2_subdev_internal_ops {
void (*unregistered)(struct v4l2_subdev *sd);
int (*open)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh);
int (*close)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh);
+ void (*release)(struct v4l2_subdev *sd);
};
#define V4L2_SUBDEV_NAME_SIZE 32