Linux Media Controller development
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Kieran Bingham <kbingham@kernel.org>
Cc: linux-renesas-soc@vger.kernel.org, linux-media@vger.kernel.org,
	sakari.ailus@iki.fi, niklas.soderlund@ragnatech.se,
	"Kieran Bingham" <kieran.bingham+renesas@ideasonboard.com>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Sakari Ailus" <sakari.ailus@linux.intel.com>,
	"Javier Martinez Canillas" <javier@osg.samsung.com>,
	"Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>,
	"Tuukka Toivonen" <tuukka.toivonen@intel.com>,
	"Javi Merino" <javi.merino@kernel.org>,
	"open list" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1 3/3] v4l: async: Match parent devices
Date: Thu, 18 May 2017 17:01:48 +0300	[thread overview]
Message-ID: <1611647.ovgU3nOQAy@avalon> (raw)
In-Reply-To: <4db2a777a71b51a864caae16385b60b4b7e9f992.1495032810.git-series.kieran.bingham+renesas@ideasonboard.com>

Hi Kieran,

Thank you for the patch.

On Wednesday 17 May 2017 16:03:39 Kieran Bingham wrote:
> From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> 
> Devices supporting multiple endpoints on a single device node must set
> their subdevice fwnode to the endpoint to allow distinct comparisons.
> 
> Adapt the match_fwnode call to compare against the provided fwnodes
> first, but also to search for a comparison against the parent fwnode.
> 
> This allows notifiers to pass the endpoint for comparison and still
> support existing subdevices which store their default parent device
> node.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> ---
>  drivers/media/v4l2-core/v4l2-async.c | 20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-async.c
> b/drivers/media/v4l2-core/v4l2-async.c index e1e181db90f7..65735a5c4350
> 100644
> --- a/drivers/media/v4l2-core/v4l2-async.c
> +++ b/drivers/media/v4l2-core/v4l2-async.c
> @@ -41,14 +41,26 @@ static bool match_devname(struct v4l2_subdev *sd,
>  	return !strcmp(asd->match.device_name.name, dev_name(sd->dev));
>  }
> 
/*
 * Check whether the two device_node pointers refer to the same OF node. We
 * can't compare pointers directly as they can differ if overlays have been
 * applied.
 */

> +static bool match_of(struct device_node *a, struct device_node *b)
> +{
> +	return !of_node_cmp(of_node_full_name(a), of_node_full_name(b));
> +}
> +
>  static bool match_fwnode(struct v4l2_subdev *sd, struct v4l2_async_subdev
> *asd)
> {
> +	struct device_node *sdnode;
> +	struct fwnode_handle *async_device;

I would name this asd_fwnode, and to be consistent rename sdnode to sd_ofnode.

> +
> +	async_device = fwnode_graph_get_port_parent(asd->match.fwnode.fwnode);
> +
>  	if (!is_of_node(sd->fwnode) || !is_of_node(asd->match.fwnode.fwnode))
> -		return sd->fwnode == asd->match.fwnode.fwnode;
> +		return sd->fwnode == asd->match.fwnode.fwnode ||
> +		       sd->fwnode == async_device;

I wonder whether we could simplify this by changing the 
fwnode_graph_get_port_parent() API. At the moment the function walks two or 
three levels up depending on whether there's a ports name or not. If we turned 
in into a function that accepts an endpoint, port or device node, and returns 
the device node unconditionally (basically, returning the argument if its name 
is not "port(@[0-9]+)?" or "endpoint(@[0-9]+)?", and walking up until it 
reaches the device node otherwise), you could write the above

	asd_fwnode = fwnode_graph_get_port_parent(asd->match.fwnode.fwnode);

  	if (!is_of_node(sd->fwnode) || !is_of_node(asd_fwnode))
		       sd->fwnode == asd_fwnode;

	sdnode = to_of_node(sd->fwnode);
 
	return match_of(sdnode, to_of_node(asd_node));

> +
> +	sdnode = to_of_node(sd->fwnode);
> 
> -	return !of_node_cmp(of_node_full_name(to_of_node(sd->fwnode)),
> -			    of_node_full_name(
> -				    to_of_node(asd->match.fwnode.fwnode)));
> +	return match_of(sdnode, to_of_node(asd->match.fwnode.fwnode)) ||
> +	       match_of(sdnode, to_of_node(async_device));

This is getting a bit complex, could you document the function ?

>  }
> 
>  static bool match_custom(struct v4l2_subdev *sd, struct v4l2_async_subdev
> *asd)

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2017-05-18 14:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-17 15:03 [PATCH v1 0/3] v4l: async: Match parent devices Kieran Bingham
2017-05-17 15:03 ` [PATCH v1 1/3] of: base: Provide of_graph_get_port_parent() Kieran Bingham
2017-05-17 16:36   ` Rob Herring
2017-05-17 20:02     ` Kieran Bingham
2017-05-17 23:53       ` Kuninori Morimoto
2017-05-18 13:18       ` Laurent Pinchart
2017-05-17 15:03 ` [PATCH v1 2/3] device property: Add fwnode_graph_get_port_parent Kieran Bingham
2017-05-18 13:36   ` Laurent Pinchart
2017-05-19 13:34     ` Kieran Bingham
2017-05-19 14:42       ` Laurent Pinchart
2017-05-22  6:18         ` Sakari Ailus
2017-05-18 15:26   ` Sakari Ailus
2017-05-17 15:03 ` [PATCH v1 3/3] v4l: async: Match parent devices Kieran Bingham
2017-05-18 14:01   ` Laurent Pinchart [this message]
2017-05-22 16:11     ` Kieran Bingham

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=1611647.ovgU3nOQAy@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=javi.merino@kernel.org \
    --cc=javier@osg.samsung.com \
    --cc=kbingham@kernel.org \
    --cc=kieran.bingham+renesas@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=niklas.soderlund@ragnatech.se \
    --cc=sakari.ailus@iki.fi \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tuukka.toivonen@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox