All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
To: Sakari Ailus <sakari.ailus@linux.intel.com>, linux-media@vger.kernel.org
Cc: linux-renesas-soc@vger.kernel.org,
	"Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>
Subject: [PATCH 2/2] rcar-csi2: Use V4L2 async helpers to create the notifier
Date: Fri,  7 Aug 2020 13:16:19 +0200	[thread overview]
Message-ID: <20200807111619.3664763-3-niklas.soderlund+renesas@ragnatech.se> (raw)
In-Reply-To: <20200807111619.3664763-1-niklas.soderlund+renesas@ragnatech.se>

The V4L2 async framework helpers now populates the async notifier with
endpoint matching information and there is no need to do this manually
in the R-Car CSI-2 driver, switch to using the provided helper.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/media/platform/rcar-vin/rcar-csi2.c | 48 +++++----------------
 1 file changed, 11 insertions(+), 37 deletions(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c
index c6cc4f473a077899..f0067ff21d5d9d33 100644
--- a/drivers/media/platform/rcar-vin/rcar-csi2.c
+++ b/drivers/media/platform/rcar-vin/rcar-csi2.c
@@ -362,7 +362,6 @@ struct rcar_csi2 {
 	struct media_pad pads[NR_OF_RCAR_CSI2_PAD];
 
 	struct v4l2_async_notifier notifier;
-	struct v4l2_async_subdev asd;
 	struct v4l2_subdev *remote;
 
 	struct v4l2_mbus_framefmt mf;
@@ -774,9 +773,11 @@ static const struct v4l2_async_notifier_operations rcar_csi2_notify_ops = {
 	.unbind = rcsi2_notify_unbind,
 };
 
-static int rcsi2_parse_v4l2(struct rcar_csi2 *priv,
-			    struct v4l2_fwnode_endpoint *vep)
+static int rcar_csi2_parse_v4l2(struct device *dev,
+				struct v4l2_fwnode_endpoint *vep,
+				struct v4l2_async_subdev *asd)
 {
+	struct rcar_csi2 *priv = dev_get_drvdata(dev);
 	unsigned int i;
 
 	/* Only port 0 endpoint 0 is valid. */
@@ -806,53 +807,26 @@ static int rcsi2_parse_v4l2(struct rcar_csi2 *priv,
 		}
 	}
 
+	dev_dbg(priv->dev, "Found '%pOF'\n", to_of_node(asd->match.fwnode));
+
 	return 0;
 }
 
 static int rcsi2_parse_dt(struct rcar_csi2 *priv)
 {
-	struct device_node *ep;
-	struct v4l2_fwnode_endpoint v4l2_ep = { .bus_type = 0 };
 	int ret;
 
-	ep = of_graph_get_endpoint_by_regs(priv->dev->of_node, 0, 0);
-	if (!ep) {
-		dev_err(priv->dev, "Not connected to subdevice\n");
-		return -EINVAL;
-	}
-
-	ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(ep), &v4l2_ep);
-	if (ret) {
-		dev_err(priv->dev, "Could not parse v4l2 endpoint\n");
-		of_node_put(ep);
-		return -EINVAL;
-	}
-
-	ret = rcsi2_parse_v4l2(priv, &v4l2_ep);
-	if (ret) {
-		of_node_put(ep);
-		return ret;
-	}
-
-	priv->asd.match.fwnode =
-		fwnode_graph_get_remote_endpoint(of_fwnode_handle(ep));
-	priv->asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
-
-	of_node_put(ep);
-
 	v4l2_async_notifier_init(&priv->notifier);
 
-	ret = v4l2_async_notifier_add_subdev(&priv->notifier, &priv->asd);
-	if (ret) {
-		fwnode_handle_put(priv->asd.match.fwnode);
+	ret = v4l2_async_notifier_parse_fwnode_endpoints_by_port(
+			priv->dev, &priv->notifier,
+			sizeof(struct v4l2_async_subdev), 0,
+			rcar_csi2_parse_v4l2);
+	if (ret)
 		return ret;
-	}
 
 	priv->notifier.ops = &rcar_csi2_notify_ops;
 
-	dev_dbg(priv->dev, "Found '%pOF'\n",
-		to_of_node(priv->asd.match.fwnode));
-
 	ret = v4l2_async_subdev_notifier_register(&priv->subdev,
 						  &priv->notifier);
 	if (ret)
-- 
2.28.0


  parent reply	other threads:[~2020-08-07 11:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-07 11:16 [PATCH 0/2] v4l: async: Switch to endpoint node matching Niklas Söderlund
2020-08-07 11:16 ` [PATCH 1/2] v4l: async: Use endpoint node, not device node, for fwnode match Niklas Söderlund
2020-08-11 22:19   ` Laurent Pinchart
2020-08-07 11:16 ` Niklas Söderlund [this message]
2020-08-10  9:36   ` [PATCH 2/2] rcar-csi2: Use V4L2 async helpers to create the notifier Jacopo Mondi
2020-08-11 22:42   ` Laurent Pinchart
2020-08-18  7:51   ` Sakari Ailus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200807111619.3664763-3-niklas.soderlund+renesas@ragnatech.se \
    --to=niklas.soderlund+renesas@ragnatech.se \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.