[PATCH v3 04/29] media: v4l2-subdev: Allow releasing frame descriptors on return
Sakari Ailus <[email protected]>
| Newsgroups | org.kernel.vger.linux-media |
|---|---|
| Organization | Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo |
| Message-ID | <[email protected]> |
Use DEFINE_FREE() to allow using __free() to release frame descriptors using v4l2_subdev_free_frame_desc(). Signed-off-by: Sakari Ailus <[email protected]> --- include/media/v4l2-subdev.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index e7127953ac22..c10ca3f5d979 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -1798,6 +1798,11 @@ int v4l2_subdev_get_frame_desc_passthrough(struct v4l2_subdev *sd, * for each frame descriptor obtained by calling this function using * v4l2_subdev_free_frame_desc(). * + * Use __free() to release the frame descriptor automatically:: + * + * struct v4l2_mbus_frame_desc *desc __free(v4l2_subdev_free_frame_desc) = + * v4l2_subdev_get_frame_desc(sd, pad, desc); + * * Return: The frame descriptor on success or a negative error code on failure. */ struct v4l2_mbus_frame_desc * @@ -1812,6 +1817,10 @@ v4l2_subdev_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, */ void v4l2_subdev_free_frame_desc(struct v4l2_mbus_frame_desc *desc); +DEFINE_FREE(v4l2_subdev_free_frame_desc, struct v4l2_mbus_frame_desc *, \ + if (!IS_ERR_OR_NULL(_T)) \ + v4l2_subdev_free_frame_desc(_T)) + #endif /* CONFIG_VIDEO_V4L2_SUBDEV_API */ #endif /* CONFIG_MEDIA_CONTROLLER */ -- 2.47.3