media: imx: imx-mipi-csis: Set the subdev fwnode for endpoint matching
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Mon, 21 Mar 2022 07:58:14 +0000 (07:58 +0000)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Sat, 16 Jul 2022 07:42:35 +0000 (08:42 +0100)
Endpoint matching is preferred over device matching with the async
notifier framework. Set the fwnode in the v4l2_subdev for the CSIS to
the endpoint connected to the next device.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/platform/nxp/imx-mipi-csis.c

index 80b1c021d14a92928cef7cbe69fa7f30020e0bc4..09a220c1bfe8ed7834bf1216ca6f3bc9a6aeca04 100644 (file)
@@ -1378,6 +1378,13 @@ static int mipi_csis_subdev_init(struct mipi_csis_device *csis)
 
        sd->dev = csis->dev;
 
+       sd->fwnode = fwnode_graph_get_endpoint_by_id(dev_fwnode(csis->dev),
+                                                    1, 0, 0);
+       if (!sd->fwnode) {
+               dev_err(csis->dev, "Unable to retrieve endpoint for port@1\n");
+               return -ENOENT;
+       }
+
        csis->csis_fmt = &mipi_csis_formats[0];
        mipi_csis_init_cfg(sd, NULL);
 
@@ -1498,6 +1505,7 @@ cleanup:
        v4l2_async_unregister_subdev(&csis->sd);
 disable_clock:
        mipi_csis_clk_disable(csis);
+       fwnode_handle_put(csis->sd.fwnode);
        mutex_destroy(&csis->lock);
 
        return ret;
@@ -1517,6 +1525,7 @@ static int mipi_csis_remove(struct platform_device *pdev)
        mipi_csis_runtime_suspend(&pdev->dev);
        mipi_csis_clk_disable(csis);
        media_entity_cleanup(&csis->sd.entity);
+       fwnode_handle_put(csis->sd.fwnode);
        mutex_destroy(&csis->lock);
        pm_runtime_set_suspended(&pdev->dev);