mbox series

[0/2] rcar-csi2: Update how DT is traversed and parsed

Message ID 20200914215011.339387-1-niklas.soderlund+renesas@ragnatech.se
Headers show
Series rcar-csi2: Update how DT is traversed and parsed | expand

Message

Niklas Söderlund Sept. 14, 2020, 9:50 p.m. UTC
Hi,

This series touches up how the R-Car CSI-2 driver traverse and parse DT 
device nodes. Patch 1/2  switches to only use the fwnode interface and 
2/2 specifies the bus type used for parsing.

This is done a preparation to later modify the rcar-vin driver in a 
similar fashion to be able to drop the use of the 
v4l2_async_notifier_parse_fwnode_endpoints_by_port() helper which I 
understand is marked for deprecation. Therefore comments on the over all 
solution of parsing DT here would be appreciated.

Niklas Söderlund (2):
  rcar-csi2: Switch to using fwnode instead of OF
  rcar-csi2: Set bus type when parsing fwnode

 drivers/media/platform/rcar-vin/rcar-csi2.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

Comments

Jacopo Mondi Sept. 15, 2020, 11:24 a.m. UTC | #1
Hi Niklas,

On Mon, Sep 14, 2020 at 11:50:10PM +0200, Niklas Söderlund wrote:
> Use the fwnode_graph_get_endpoint_by_id() interface instead of
> of_graph_get_endpoint_by_regs() to fetch the fwnode. This saves
> translating between a device_node and fwnode_handle.
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

Looks good
Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>

Thanks
  j

> ---
>  drivers/media/platform/rcar-vin/rcar-csi2.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c
> index 511cd4984777ad99..23e89ef2429d310a 100644
> --- a/drivers/media/platform/rcar-vin/rcar-csi2.c
> +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c
> @@ -873,31 +873,31 @@ static int rcsi2_parse_dt(struct rcar_csi2 *priv)
>  {
>  	struct v4l2_async_subdev *asd;
>  	struct fwnode_handle *fwnode;
> -	struct device_node *ep;
> +	struct fwnode_handle *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);
> +	ep = fwnode_graph_get_endpoint_by_id(dev_fwnode(priv->dev), 0, 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);
> +	ret = v4l2_fwnode_endpoint_parse(ep, &v4l2_ep);
>  	if (ret) {
>  		dev_err(priv->dev, "Could not parse v4l2 endpoint\n");
> -		of_node_put(ep);
> +		fwnode_handle_put(ep);
>  		return -EINVAL;
>  	}
>
>  	ret = rcsi2_parse_v4l2(priv, &v4l2_ep);
>  	if (ret) {
> -		of_node_put(ep);
> +		fwnode_handle_put(ep);
>  		return ret;
>  	}
>
> -	fwnode = fwnode_graph_get_remote_endpoint(of_fwnode_handle(ep));
> -	of_node_put(ep);
> +	fwnode = fwnode_graph_get_remote_endpoint(ep);
> +	fwnode_handle_put(ep);
>
>  	dev_dbg(priv->dev, "Found '%pOF'\n", to_of_node(fwnode));
>
> --
> 2.28.0
>