media: exynos4-is: Use global num_sensors rather than local index
authorJonathan Bakker <xc-racer2@live.ca>
Thu, 30 Jul 2020 23:01:09 +0000 (01:01 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 1 Sep 2020 12:13:25 +0000 (14:13 +0200)
Instead of keeping a local copy of how many sensors we've probed
(which may not even properly represent the number of sensors
probed if we have a port without a sensor), use the global
num_sensors counter that has the actual number used.

This will also make it easier to add support for multiple sensors
being connected to the same port.

Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/platform/exynos4-is/media-dev.c

index aae584f..1ca9050 100644 (file)
@@ -397,9 +397,9 @@ static void fimc_md_pipelines_free(struct fimc_md *fmd)
 
 /* Parse port node and register as a sub-device any sensor specified there. */
 static int fimc_md_parse_port_node(struct fimc_md *fmd,
-                                  struct device_node *port,
-                                  unsigned int index)
+                                  struct device_node *port)
 {
+       int index = fmd->num_sensors;
        struct fimc_source_info *pd = &fmd->sensor[index].pdata;
        struct device_node *rem, *ep, *np;
        struct v4l2_fwnode_endpoint endpoint = { .bus_type = 0 };
@@ -489,7 +489,6 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)
        struct device_node *parent = fmd->pdev->dev.of_node;
        struct device_node *ports = NULL;
        struct device_node *node;
-       int index = 0;
        int ret;
 
        /*
@@ -516,13 +515,12 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)
                if (!port)
                        continue;
 
-               ret = fimc_md_parse_port_node(fmd, port, index);
+               ret = fimc_md_parse_port_node(fmd, port);
                of_node_put(port);
                if (ret < 0) {
                        of_node_put(node);
                        goto cleanup;
                }
-               index++;
        }
 
        /* Attach sensors listed in the parallel-ports node */
@@ -531,12 +529,11 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)
                goto rpm_put;
 
        for_each_child_of_node(ports, node) {
-               ret = fimc_md_parse_port_node(fmd, node, index);
+               ret = fimc_md_parse_port_node(fmd, node);
                if (ret < 0) {
                        of_node_put(node);
                        goto cleanup;
                }
-               index++;
        }
        of_node_put(ports);