diff mbox series

[v2,06/11] media: exynos4-is: Use global num_sensors rather than local index

Message ID BN6PR04MB066025E2D254EF0E5383B7FCA3710@BN6PR04MB0660.namprd04.prod.outlook.com (mailing list archive)
State Not Applicable
Headers show
Series [v2,01/11] media: exynos4-is: Remove static driver data for S5PV210 FIMC variants | expand

Commit Message

Jonathan Bakker July 30, 2020, 11:01 p.m. UTC
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>
---
Changes from v1:
- New patch
---
 drivers/media/platform/exynos4-is/media-dev.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

Comments

On 31.07.2020 01:01, Jonathan Bakker wrote:
> 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>
diff mbox series

Patch

diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
index 5c32abc7251b..70b0a70840cf 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -396,9 +396,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 };
@@ -488,7 +488,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;
 
 	/*
@@ -515,13 +514,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 */
@@ -530,12 +528,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);