]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: platform: ti: use for_each_endpoint_of_node()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tue, 30 Jul 2024 00:35:00 +0000 (00:35 +0000)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Fri, 9 Aug 2024 05:56:39 +0000 (07:56 +0200)
We already have for_each_endpoint_of_node(), don't use
of_graph_get_next_endpoint() directly. Replace it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/platform/ti/am437x/am437x-vpfe.c
drivers/media/platform/ti/davinci/vpif_capture.c

index 77e12457d1495f90523a8cde0df18d1be20f2739..009ff68a2b43ca559f0531024c9e039d19472931 100644 (file)
@@ -2287,7 +2287,7 @@ static const struct v4l2_async_notifier_operations vpfe_async_ops = {
 static struct vpfe_config *
 vpfe_get_pdata(struct vpfe_device *vpfe)
 {
-       struct device_node *endpoint = NULL;
+       struct device_node *endpoint;
        struct device *dev = vpfe->pdev;
        struct vpfe_subdev_info *sdinfo;
        struct vpfe_config *pdata;
@@ -2306,14 +2306,11 @@ vpfe_get_pdata(struct vpfe_device *vpfe)
        if (!pdata)
                return NULL;
 
-       for (i = 0; ; i++) {
+       i = 0;
+       for_each_endpoint_of_node(dev->of_node, endpoint) {
                struct v4l2_fwnode_endpoint bus_cfg = { .bus_type = 0 };
                struct device_node *rem;
 
-               endpoint = of_graph_get_next_endpoint(dev->of_node, endpoint);
-               if (!endpoint)
-                       break;
-
                sdinfo = &pdata->sub_devs[i];
                sdinfo->grp_id = 0;
 
@@ -2371,9 +2368,10 @@ vpfe_get_pdata(struct vpfe_device *vpfe)
                of_node_put(rem);
                if (IS_ERR(pdata->asd[i]))
                        goto cleanup;
+
+               i++;
        }
 
-       of_node_put(endpoint);
        return pdata;
 
 cleanup:
index c28794b6677b77fca7bb1699b8d3c289f1e548ba..16326437767f803f4f474bfbd1d76e6bd001e8ec 100644 (file)
@@ -1487,7 +1487,7 @@ static struct vpif_capture_config *
 vpif_capture_get_pdata(struct platform_device *pdev,
                       struct v4l2_device *v4l2_dev)
 {
-       struct device_node *endpoint = NULL;
+       struct device_node *endpoint;
        struct device_node *rem = NULL;
        struct vpif_capture_config *pdata;
        struct vpif_subdev_info *sdinfo;
@@ -1517,16 +1517,12 @@ vpif_capture_get_pdata(struct platform_device *pdev,
        if (!pdata->subdev_info)
                return NULL;
 
-       for (i = 0; i < VPIF_CAPTURE_NUM_CHANNELS; i++) {
+       i = 0;
+       for_each_endpoint_of_node(pdev->dev.of_node, endpoint) {
                struct v4l2_fwnode_endpoint bus_cfg = { .bus_type = 0 };
                unsigned int flags;
                int err;
 
-               endpoint = of_graph_get_next_endpoint(pdev->dev.of_node,
-                                                     endpoint);
-               if (!endpoint)
-                       break;
-
                rem = of_graph_get_remote_port_parent(endpoint);
                if (!rem) {
                        dev_dbg(&pdev->dev, "Remote device at %pOF not found\n",
@@ -1577,6 +1573,10 @@ vpif_capture_get_pdata(struct platform_device *pdev,
                        goto err_cleanup;
 
                of_node_put(rem);
+
+               i++;
+               if (i >= VPIF_CAPTURE_NUM_CHANNELS)
+                       break;
        }
 
 done: