diff mbox series

[v2,4/4] media: v4l2-async: Don't check fwnode name to detect endpoint

Message ID 20200318002507.30336-5-laurent.pinchart+renesas@ideasonboard.com (mailing list archive)
State New, archived
Headers show
Series media: v4l2-async: Accept endpoints and devices for fwnode matching | expand

Commit Message

Laurent Pinchart March 18, 2020, 12:25 a.m. UTC
Use the presence of a "remote-endpoint" property to detect if a fwnode
is an endpoint node, as checking the node name won't work on ACPI-based
implementations.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/media/v4l2-core/v4l2-async.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

Kieran Bingham March 18, 2020, 9:22 a.m. UTC | #1
Hi Laurent,

On 18/03/2020 00:25, Laurent Pinchart wrote:
> Use the presence of a "remote-endpoint" property to detect if a fwnode
> is an endpoint node, as checking the node name won't work on ACPI-based
> implementations.

Technically, won't this property only detect that the endpoint is
connected to another endpoint, and 'un-connected' endpoints wont' match?

Of course in this instance - an unconnected endpoint is likely not much
use and probably even shouldn't match ;-) ~(but it may still 'be' an
endpoint).

Also - would this patch be squashed into 1/4?

I'll leave it to Sakari to comment on the actual validity of this
approach all the same :-)

--
Kieran


> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>  drivers/media/v4l2-core/v4l2-async.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
> index 9f393a7be455..a5f83ba502df 100644
> --- a/drivers/media/v4l2-core/v4l2-async.c
> +++ b/drivers/media/v4l2-core/v4l2-async.c
> @@ -78,7 +78,6 @@ static bool match_fwnode(struct v4l2_async_notifier *notifier,
>  	bool asd_fwnode_is_ep;
>  	bool sd_fwnode_is_ep;
>  	struct device *dev;
> -	const char *name;
>  
>  	/*
>  	 * Both the subdev and the async subdev can provide either an endpoint
> @@ -92,10 +91,10 @@ static bool match_fwnode(struct v4l2_async_notifier *notifier,
>  	 * Otherwise, check if the sd fwnode and the asd fwnode refer to an
>  	 * endpoint or a device. If they're of the same type, there's no match.
>  	 */
> -	name = fwnode_get_name(sd->fwnode);
> -	sd_fwnode_is_ep = name && strstarts(name, "endpoint");
> -	name = fwnode_get_name(asd->match.fwnode);
> -	asd_fwnode_is_ep = name && strstarts(name, "endpoint");
> +	sd_fwnode_is_ep = fwnode_property_present(sd->fwnode,
> +						  "remote-endpoint");
> +	asd_fwnode_is_ep = fwnode_property_present(asd->match.fwnode,
> +						   "remote-endpoint");
>  
>  	if (sd_fwnode_is_ep == asd_fwnode_is_ep)
>  		return false;
>
Laurent Pinchart June 20, 2020, 11:04 p.m. UTC | #2
Hi Kieran,

On Wed, Mar 18, 2020 at 09:22:21AM +0000, Kieran Bingham wrote:
> On 18/03/2020 00:25, Laurent Pinchart wrote:
> > Use the presence of a "remote-endpoint" property to detect if a fwnode
> > is an endpoint node, as checking the node name won't work on ACPI-based
> > implementations.
> 
> Technically, won't this property only detect that the endpoint is
> connected to another endpoint, and 'un-connected' endpoints wont' match?
> 
> Of course in this instance - an unconnected endpoint is likely not much
> use and probably even shouldn't match ;-) ~(but it may still 'be' an
> endpoint).

Yes, technically speaking, this detects whether the node is an endpoint
and is connected. As you mentioned, there's little use in unconnected
endpoints here, as nobody would attempt to match them.

> Also - would this patch be squashed into 1/4?

I think that would make sense, yes. I'll do so in v3.

> I'll leave it to Sakari to comment on the actual validity of this
> approach all the same :-)

ACPI has a remote-endpoint property, but has no endpoint nodes. I wonder
what the remote-endpoint points to...

> > Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> > ---
> >  drivers/media/v4l2-core/v4l2-async.c | 9 ++++-----
> >  1 file changed, 4 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
> > index 9f393a7be455..a5f83ba502df 100644
> > --- a/drivers/media/v4l2-core/v4l2-async.c
> > +++ b/drivers/media/v4l2-core/v4l2-async.c
> > @@ -78,7 +78,6 @@ static bool match_fwnode(struct v4l2_async_notifier *notifier,
> >  	bool asd_fwnode_is_ep;
> >  	bool sd_fwnode_is_ep;
> >  	struct device *dev;
> > -	const char *name;
> >  
> >  	/*
> >  	 * Both the subdev and the async subdev can provide either an endpoint
> > @@ -92,10 +91,10 @@ static bool match_fwnode(struct v4l2_async_notifier *notifier,
> >  	 * Otherwise, check if the sd fwnode and the asd fwnode refer to an
> >  	 * endpoint or a device. If they're of the same type, there's no match.
> >  	 */
> > -	name = fwnode_get_name(sd->fwnode);
> > -	sd_fwnode_is_ep = name && strstarts(name, "endpoint");
> > -	name = fwnode_get_name(asd->match.fwnode);
> > -	asd_fwnode_is_ep = name && strstarts(name, "endpoint");
> > +	sd_fwnode_is_ep = fwnode_property_present(sd->fwnode,
> > +						  "remote-endpoint");
> > +	asd_fwnode_is_ep = fwnode_property_present(asd->match.fwnode,
> > +						   "remote-endpoint");
> >  
> >  	if (sd_fwnode_is_ep == asd_fwnode_is_ep)
> >  		return false;
diff mbox series

Patch

diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
index 9f393a7be455..a5f83ba502df 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -78,7 +78,6 @@  static bool match_fwnode(struct v4l2_async_notifier *notifier,
 	bool asd_fwnode_is_ep;
 	bool sd_fwnode_is_ep;
 	struct device *dev;
-	const char *name;
 
 	/*
 	 * Both the subdev and the async subdev can provide either an endpoint
@@ -92,10 +91,10 @@  static bool match_fwnode(struct v4l2_async_notifier *notifier,
 	 * Otherwise, check if the sd fwnode and the asd fwnode refer to an
 	 * endpoint or a device. If they're of the same type, there's no match.
 	 */
-	name = fwnode_get_name(sd->fwnode);
-	sd_fwnode_is_ep = name && strstarts(name, "endpoint");
-	name = fwnode_get_name(asd->match.fwnode);
-	asd_fwnode_is_ep = name && strstarts(name, "endpoint");
+	sd_fwnode_is_ep = fwnode_property_present(sd->fwnode,
+						  "remote-endpoint");
+	asd_fwnode_is_ep = fwnode_property_present(asd->match.fwnode,
+						   "remote-endpoint");
 
 	if (sd_fwnode_is_ep == asd_fwnode_is_ep)
 		return false;