Commit e22f709e authored by Niklas Söderlund's avatar Niklas Söderlund Committed by Mauro Carvalho Chehab

[media] v4l: of: check for unique lanes in data-lanes and clock-lanes

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: default avatarNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent d2fe28fe
...@@ -26,7 +26,7 @@ static int v4l2_of_parse_csi_bus(const struct device_node *node, ...@@ -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 v4l2_of_bus_mipi_csi2 *bus = &endpoint->bus.mipi_csi2;
struct property *prop; struct property *prop;
bool have_clk_lane = false; bool have_clk_lane = false;
unsigned int flags = 0; unsigned int flags = 0, lanes_used = 0;
u32 v; u32 v;
prop = of_find_property(node, "data-lanes", NULL); prop = of_find_property(node, "data-lanes", NULL);
...@@ -38,6 +38,12 @@ static int v4l2_of_parse_csi_bus(const struct device_node *node, ...@@ -38,6 +38,12 @@ static int v4l2_of_parse_csi_bus(const struct device_node *node,
lane = of_prop_next_u32(prop, lane, &v); lane = of_prop_next_u32(prop, lane, &v);
if (!lane) if (!lane)
break; 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->data_lanes[i] = v;
} }
bus->num_data_lanes = i; bus->num_data_lanes = i;
...@@ -63,6 +69,11 @@ static int v4l2_of_parse_csi_bus(const struct device_node *node, ...@@ -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 (!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; bus->clock_lane = v;
have_clk_lane = true; have_clk_lane = true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment