From e22f709e055e0e71d65ae9bb9bf6d32c31f3a1ac Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niklas=20S=C3=B6derlund?= Date: Tue, 31 Jan 2017 10:08:31 -0200 Subject: [PATCH] [media] v4l: of: check for unique lanes in data-lanes and clock-lanes MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit All lanes in data-lanes and clock-lanes properties should be unique. Add a check for this in v4l2_of_parse_csi_bus() and print a warning if duplicated lanes are found. Signed-off-by: Niklas Söderlund Acked-by: Sakari Ailus Reviewed-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-of.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/media/v4l2-core/v4l2-of.c b/drivers/media/v4l2-core/v4l2-of.c index 93b33681776c..4f59f442dd0a 100644 --- a/drivers/media/v4l2-core/v4l2-of.c +++ b/drivers/media/v4l2-core/v4l2-of.c @@ -26,7 +26,7 @@ static int v4l2_of_parse_csi_bus(const struct device_node *node, struct v4l2_of_bus_mipi_csi2 *bus = &endpoint->bus.mipi_csi2; struct property *prop; bool have_clk_lane = false; - unsigned int flags = 0; + unsigned int flags = 0, lanes_used = 0; u32 v; prop = of_find_property(node, "data-lanes", NULL); @@ -38,6 +38,12 @@ static int v4l2_of_parse_csi_bus(const struct device_node *node, lane = of_prop_next_u32(prop, lane, &v); if (!lane) break; + + if (lanes_used & BIT(v)) + pr_warn("%s: duplicated lane %u in data-lanes\n", + node->full_name, v); + lanes_used |= BIT(v); + bus->data_lanes[i] = v; } bus->num_data_lanes = i; @@ -63,6 +69,11 @@ static int v4l2_of_parse_csi_bus(const struct device_node *node, } if (!of_property_read_u32(node, "clock-lanes", &v)) { + if (lanes_used & BIT(v)) + pr_warn("%s: duplicated lane %u in clock-lanes\n", + node->full_name, v); + lanes_used |= BIT(v); + bus->clock_lane = v; have_clk_lane = true; } -- 2.20.1