[PATCH v3 19/29] media: nxp: imx8-isi: Use v4l2_subdev_get_frame_desc()

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]>
Call v4l2_subdev_get_frame_desc() to obtain the frame descriptor. This is
preferred over calling the get_frame_desc() pad operation directly.

Signed-off-by: Sakari Ailus <[email protected]>
Reviewed-by: Frank Li <[email protected]>
---
 .../platform/nxp/imx8-isi/imx8-isi-crossbar.c | 19 +++++++--------
 .../platform/nxp/imx8-isi/imx8-isi-pipe.c     | 23 +++++++++----------
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
index e6c38a769205..5aef5cd179cf 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c
@@ -5,6 +5,7 @@
  * Copyright (c) 2022 Laurent Pinchart <[email protected]>
  */
 
+#include <linux/cleanup.h>
 #include <linux/device.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
@@ -32,8 +33,6 @@ static int mxc_isi_crossbar_gasket_enable(struct mxc_isi_crossbar *xbar,
 	struct mxc_isi_dev *isi = xbar->isi;
 	const struct mxc_gasket_ops *gasket_ops = isi->pdata->gasket_ops;
 	const struct v4l2_mbus_framefmt *fmt;
-	struct v4l2_mbus_frame_desc fd;
-	int ret;
 
 	if (!gasket_ops)
 		return 0;
@@ -44,15 +43,17 @@ static int mxc_isi_crossbar_gasket_enable(struct mxc_isi_crossbar *xbar,
 	 * to match the configuration of the CSIS.
 	 */
 
-	ret = v4l2_subdev_call(remote_sd, pad, get_frame_desc, remote_pad, &fd);
-	if (ret) {
+	struct v4l2_mbus_frame_desc *fd __free(v4l2_subdev_free_frame_desc) =
+		v4l2_subdev_get_frame_desc(remote_sd, remote_pad,
+					   V4L2_MBUS_FRAME_DESC_TYPE_PARALLEL);
+	if (IS_ERR(fd)) {
 		dev_err(isi->dev,
-			"failed to get frame descriptor from '%s':%u: %d\n",
-			remote_sd->name, remote_pad, ret);
-		return ret;
+			"failed to get frame descriptor from '%s':%u: %pe\n",
+			remote_sd->name, remote_pad, fd);
+		return PTR_ERR(fd);
 	}
 
-	if (fd.num_entries != 1) {
+	if (fd->num_entries != 1) {
 		dev_err(isi->dev, "invalid frame descriptor for '%s':%u\n",
 			remote_sd->name, remote_pad);
 		return -EINVAL;
@@ -62,7 +63,7 @@ static int mxc_isi_crossbar_gasket_enable(struct mxc_isi_crossbar *xbar,
 	if (!fmt)
 		return -EINVAL;
 
-	gasket_ops->enable(isi, &fd, fmt, port);
+	gasket_ops->enable(isi, fd, fmt, port);
 	return 0;
 }
 
diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-pipe.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-pipe.c
index 934f7b356258..12b296d7bbe0 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-pipe.c
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-pipe.c
@@ -266,27 +266,26 @@ static int mxc_isi_get_vc(struct mxc_isi_pipe *pipe)
 {
 	struct mxc_isi_crossbar *xbar = &pipe->isi->crossbar;
 	struct device *dev = pipe->isi->dev;
-	struct v4l2_mbus_frame_desc fd = { };
 	unsigned int source_pad = xbar->num_sinks + pipe->id;
 	unsigned int num_vcs;
 	unsigned int i;
-	int ret;
 
-	ret = v4l2_subdev_call(&xbar->sd, pad, get_frame_desc,
-			       source_pad, &fd);
-	if (ret < 0) {
+	struct v4l2_mbus_frame_desc *fd __free(v4l2_subdev_free_frame_desc) =
+		v4l2_subdev_get_frame_desc(&xbar->sd, source_pad,
+					   V4L2_MBUS_FRAME_DESC_TYPE_CSI2);
+	if (IS_ERR(fd)) {
 		dev_err(dev, "Failed to get source frame desc from pad %u\n",
 			source_pad);
-		return ret;
+		return PTR_ERR(fd);
 	}
 
 	/* Find stream 0 in the frame descriptor. */
-	for (i = 0; i < fd.num_entries; i++) {
-		if (fd.entry[i].stream == 0)
+	for (i = 0; i < fd->num_entries; i++) {
+		if (fd->entry[i].stream == 0)
 			break;
 	}
 
-	if (i == fd.num_entries) {
+	if (i == fd->num_entries) {
 		dev_err(dev, "Failed to find stream from source frame desc\n");
 		return -EPIPE;
 	}
@@ -294,13 +293,13 @@ static int mxc_isi_get_vc(struct mxc_isi_pipe *pipe)
 	num_vcs = pipe->isi->pdata->num_vc ? : 1;
 
 	/* Check virtual channel range. */
-	if (fd.entry[i].bus.csi2.vc >= num_vcs) {
+	if (fd->entry[i].bus.csi2.vc >= num_vcs) {
 		dev_err(dev, "Virtual channel %u exceeds maximum %u\n",
-			fd.entry[i].bus.csi2.vc, num_vcs - 1);
+			fd->entry[i].bus.csi2.vc, num_vcs - 1);
 		return -EPIPE;
 	}
 
-	return fd.entry[i].bus.csi2.vc;
+	return fd->entry[i].bus.csi2.vc;
 }
 
 int mxc_isi_pipe_enable(struct mxc_isi_pipe *pipe)
-- 
2.47.3
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.