[PATCH 10/22] media: st-mipid02: Fix fwnode media link creation

From: Steve Longerbeam
Date: Mon Aug 05 2019 - 19:36:31 EST


mipid02_async_bound() passes the bound subdev's sd->fwnode to
media_entity_get_fwnode_pad(). This is likely not an endpoint
fwnode as required by media_entity_get_fwnode_pad(), for most
subdevices it is the port parent of endpoint fwnode(s). This has only
worked before because no entities have implemented the .get_fwnode_pad()
op yet, and the default behavior of media_entity_get_fwnode_pad()
was to ignore the passed fwnode and return the first pad that matches
the given direction flags.

Fix this by replacing the calls to media_entity_get_fwnode_pad() and
media_create_pad_link() with a call to media_create_fwnode_pad_links().

Fixes: 642bb5e88fed8 ("media: st-mipid02: MIPID02 CSI-2 to PARALLEL
bridge driver")

Signed-off-by: Steve Longerbeam <slongerbeam@xxxxxxxxx>
---
drivers/media/i2c/st-mipid02.c | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/drivers/media/i2c/st-mipid02.c b/drivers/media/i2c/st-mipid02.c
index 81285b8d5cfb..b26d5550874f 100644
--- a/drivers/media/i2c/st-mipid02.c
+++ b/drivers/media/i2c/st-mipid02.c
@@ -798,24 +798,16 @@ static int mipid02_async_bound(struct v4l2_async_notifier *notifier,
{
struct mipid02_dev *bridge = to_mipid02_dev(notifier->sd);
struct i2c_client *client = bridge->i2c_client;
- int source_pad;
int ret;

dev_dbg(&client->dev, "sensor_async_bound call %p", s_subdev);

- source_pad = media_entity_get_fwnode_pad(&s_subdev->entity,
- s_subdev->fwnode,
- MEDIA_PAD_FL_SOURCE);
- if (source_pad < 0) {
- dev_err(&client->dev, "Couldn't find output pad for subdev %s\n",
- s_subdev->name);
- return source_pad;
- }
-
- ret = media_create_pad_link(&s_subdev->entity, source_pad,
- &bridge->sd.entity, 0,
- MEDIA_LNK_FL_ENABLED |
- MEDIA_LNK_FL_IMMUTABLE);
+ ret = media_create_fwnode_pad_links(&bridge->sd.entity.pads[0],
+ dev_fwnode(&client->dev),
+ &s_subdev->entity,
+ dev_fwnode(s_subdev->dev),
+ MEDIA_LNK_FL_ENABLED |
+ MEDIA_LNK_FL_IMMUTABLE);
if (ret) {
dev_err(&client->dev, "Couldn't create media link %d", ret);
return ret;
--
2.17.1