diff mbox series

[v5,04/16] media: sun6i-csi: Stop using the deprecated fwnode endpoint parser

Message ID 20210115200141.1397785-5-paul.kocialkowski@bootlin.com
State New
Headers show
Series Allwinner MIPI CSI-2 support for A31/V3s/A83T | expand

Commit Message

Paul Kocialkowski Jan. 15, 2021, 8:01 p.m. UTC
The v4l2_async_notifier_parse_fwnode_endpoints helper is getting
deprecated in favor of explicit parsing of the endpoints.

Implement it instead of using this deprecated function.

Since this was the last user of the helper, it should now be safe to
remove.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 .../platform/sunxi/sun6i-csi/sun6i_csi.c      | 69 ++++++++++++-------
 .../platform/sunxi/sun6i-csi/sun6i_csi.h      |  1 +
 2 files changed, 44 insertions(+), 26 deletions(-)

Comments

Maxime Ripard Jan. 18, 2021, 9:09 a.m. UTC | #1
Hi,

Thanks for working on this

On Fri, Jan 15, 2021 at 09:01:29PM +0100, Paul Kocialkowski wrote:
> The v4l2_async_notifier_parse_fwnode_endpoints helper is getting

> deprecated in favor of explicit parsing of the endpoints.

> 

> Implement it instead of using this deprecated function.

> 

> Since this was the last user of the helper, it should now be safe to

> remove.

> 

> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>


Acked-by: Maxime Ripard <mripard@kernel.org>


Maxime
diff mbox series

Patch

diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
index c3b2f27b99d2..1a11a6174a17 100644
--- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
+++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
@@ -693,28 +693,6 @@  static const struct v4l2_async_notifier_operations sun6i_csi_async_ops = {
 	.complete = sun6i_subdev_notify_complete,
 };
 
-static int sun6i_csi_fwnode_parse(struct device *dev,
-				  struct v4l2_fwnode_endpoint *vep,
-				  struct v4l2_async_subdev *asd)
-{
-	struct sun6i_csi *csi = dev_get_drvdata(dev);
-
-	if (vep->base.port || vep->base.id) {
-		dev_warn(dev, "Only support a single port with one endpoint\n");
-		return -ENOTCONN;
-	}
-
-	switch (vep->bus_type) {
-	case V4L2_MBUS_PARALLEL:
-	case V4L2_MBUS_BT656:
-		csi->v4l2_ep = *vep;
-		return 0;
-	default:
-		dev_err(dev, "Unsupported media bus type\n");
-		return -ENOTCONN;
-	}
-}
-
 static void sun6i_csi_v4l2_cleanup(struct sun6i_csi *csi)
 {
 	media_device_unregister(&csi->media_dev);
@@ -726,6 +704,48 @@  static void sun6i_csi_v4l2_cleanup(struct sun6i_csi *csi)
 	media_device_cleanup(&csi->media_dev);
 }
 
+static int sun6i_csi_v4l2_fwnode_init(struct sun6i_csi *csi)
+{
+	struct v4l2_fwnode_endpoint *endpoint = NULL;
+	struct fwnode_handle *handle = NULL;
+	int ret;
+
+	/* Parallel */
+
+	endpoint = &csi->v4l2_ep;
+	handle = fwnode_graph_get_endpoint_by_id(dev_fwnode(csi->dev), 0, 0,
+						 FWNODE_GRAPH_ENDPOINT_NEXT);
+	if (!handle)
+		return 0;
+
+	ret = v4l2_fwnode_endpoint_parse(handle, endpoint);
+	if (ret)
+		goto error;
+
+	if (endpoint->bus_type != V4L2_MBUS_PARALLEL &&
+	    endpoint->bus_type != V4L2_MBUS_BT656) {
+		dev_err(csi->dev, "Unsupported parallel media bus type\n");
+		ret = -ENOTCONN;
+		goto error;
+	}
+
+	ret = v4l2_async_notifier_add_fwnode_remote_subdev(&csi->notifier,
+							   handle,
+							   &csi->subdev);
+	if (ret)
+		goto error;
+
+	fwnode_handle_put(handle);
+
+	return 0;
+
+error:
+	if (handle)
+		fwnode_handle_put(handle);
+
+	return ret;
+}
+
 static int sun6i_csi_v4l2_init(struct sun6i_csi *csi)
 {
 	int ret;
@@ -760,10 +780,7 @@  static int sun6i_csi_v4l2_init(struct sun6i_csi *csi)
 	if (ret)
 		goto unreg_v4l2;
 
-	ret = v4l2_async_notifier_parse_fwnode_endpoints(csi->dev,
-							 &csi->notifier,
-							 sizeof(struct v4l2_async_subdev),
-							 sun6i_csi_fwnode_parse);
+	ret = sun6i_csi_v4l2_fwnode_init(csi);
 	if (ret)
 		goto clean_video;
 
diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h
index c626821aaedb..7f3389c70794 100644
--- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h
+++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h
@@ -38,6 +38,7 @@  struct sun6i_csi {
 	struct v4l2_device		v4l2_dev;
 	struct media_device		media_dev;
 
+	struct v4l2_async_subdev	subdev;
 	struct v4l2_async_notifier	notifier;
 
 	/* video port settings */