Skip to contentSkip to conversation

v4l2: mc: fix endpoint iteration

PATCH In review Cosmin Tanislav 3 participants 3 messages Nov 22, 2024 – Dec 13, 2024 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 v4l2: mc: fix endpoint iteration

When creating links from a subdev to a sink, the current logic tries to iterate over the endpoints of dev's fwnode.

This might not be correct when the subdev uses a different fwnode compared to the dev's fwnode.

If, when registering, the subdev's fwnode is not set, the code inside v4l2_async_register_subdev will set it to the dev's fwnode.

To fix this, just use the subdev's fwnode.

Fixes 0d3c81e82da9 ("media: v4l2-mc: add v4l2_create_fwnode_links helpers")
---
 drivers/media/v4l2-core/v4l2-mc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-mc.c +1 -1
index 4bb91359e3a9a..937d358697e19 100644
@@ -329,7 +329,7 @@ int v4l2_create_fwnode_links_to_pad(struct v4l2_subdev *src_sd,
 	if (!(sink->flags & MEDIA_PAD_FL_SINK))
 		return -EINVAL;
 
-	fwnode_graph_for_each_endpoint(dev_fwnode(src_sd->dev), endpoint) {
+	fwnode_graph_for_each_endpoint(src_sd->fwnode, endpoint) {
 		struct fwnode_handle *remote_ep;
 		int src_idx, sink_idx, ret;
 		struct media_pad *src;
Signature · 1 line
2.47.0
Reviewed-by on v1 1/1
#1 lore raw

Hi Cosmin,

Thank you for the patch.

Quoted 6 lines · Cosmin Tanislav

When creating links from a subdev to a sink, the current logic tries to iterate over the endpoints of dev's fwnode.

This might not be correct when the subdev uses a different fwnode compared to the dev's fwnode.

Quoted 7 lines

If, when registering, the subdev's fwnode is not set, the code inside v4l2_async_register_subdev will set it to the dev's fwnode.

To fix this, just use the subdev's fwnode.

Fixes 0d3c81e82da9 ("media: v4l2-mc: add v4l2_create_fwnode_links helpers")
Quoted 17 lines
---
 drivers/media/v4l2-core/v4l2-mc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-mc.c +1 -1
index 4bb91359e3a9a..937d358697e19 100644
@@ -329,7 +329,7 @@ int v4l2_create_fwnode_links_to_pad(struct v4l2_subdev *src_sd,
 	if (!(sink->flags & MEDIA_PAD_FL_SINK))
 		return -EINVAL;
 
-	fwnode_graph_for_each_endpoint(dev_fwnode(src_sd->dev), endpoint) {
+	fwnode_graph_for_each_endpoint(src_sd->fwnode, endpoint) {
 		struct fwnode_handle *remote_ep;
 		int src_idx, sink_idx, ret;
 		struct media_pad *src;
Signature · 3 lines
Regards,

Laurent Pinchart
#2 lore raw
In reply to Cosmin Tanislav

Hi Cosmin,

Quoted 6 lines · Cosmin Tanislav

When creating links from a subdev to a sink, the current logic tries to iterate over the endpoints of dev's fwnode.

This might not be correct when the subdev uses a different fwnode compared to the dev's fwnode.

Quoted 7 lines

If, when registering, the subdev's fwnode is not set, the code inside v4l2_async_register_subdev will set it to the dev's fwnode.

To fix this, just use the subdev's fwnode.

Fixes 0d3c81e82da9 ("media: v4l2-mc: add v4l2_create_fwnode_links helpers")

Nowadays Fixes: (almost) requires Cc: stable. I'll add that this time.

Quoted 17 lines
---
 drivers/media/v4l2-core/v4l2-mc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-mc.c +1 -1
index 4bb91359e3a9a..937d358697e19 100644
@@ -329,7 +329,7 @@ int v4l2_create_fwnode_links_to_pad(struct v4l2_subdev *src_sd,
 	if (!(sink->flags & MEDIA_PAD_FL_SINK))
 		return -EINVAL;
 
-	fwnode_graph_for_each_endpoint(dev_fwnode(src_sd->dev), endpoint) {
+	fwnode_graph_for_each_endpoint(src_sd->fwnode, endpoint) {
 		struct fwnode_handle *remote_ep;
 		int src_idx, sink_idx, ret;
 		struct media_pad *src;
Signature · 3 lines
Regards,

Sakari Ailus