Commit af11a74a authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab

media: v4l: fwnode: Only assign configuration if there is no error

Only assign endpoint configuration if the endpoint is parsed successfully.
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: default avatarSteve Longerbeam <steve_longerbeam@mentor.com>
Tested-by: default avatarJacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 276565ed
...@@ -47,7 +47,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, ...@@ -47,7 +47,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
enum v4l2_fwnode_bus_type bus_type) enum v4l2_fwnode_bus_type bus_type)
{ {
struct v4l2_fwnode_bus_mipi_csi2 *bus = &vep->bus.mipi_csi2; struct v4l2_fwnode_bus_mipi_csi2 *bus = &vep->bus.mipi_csi2;
bool have_clk_lane = false; bool have_clk_lane = false, have_lane_polarities = false;
unsigned int flags = 0, lanes_used = 0; unsigned int flags = 0, lanes_used = 0;
u32 array[1 + V4L2_FWNODE_CSI2_MAX_DATA_LANES]; u32 array[1 + V4L2_FWNODE_CSI2_MAX_DATA_LANES];
unsigned int num_data_lanes = 0; unsigned int num_data_lanes = 0;
...@@ -73,7 +73,6 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, ...@@ -73,7 +73,6 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
array[i]); array[i]);
lanes_used |= BIT(array[i]); lanes_used |= BIT(array[i]);
bus->data_lanes[i] = array[i];
pr_debug("lane %u position %u\n", i, array[i]); pr_debug("lane %u position %u\n", i, array[i]);
} }
} }
...@@ -87,16 +86,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, ...@@ -87,16 +86,7 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
return -EINVAL; return -EINVAL;
} }
fwnode_property_read_u32_array(fwnode, "lane-polarities", array, have_lane_polarities = true;
1 + num_data_lanes);
for (i = 0; i < 1 + num_data_lanes; i++) {
bus->lane_polarities[i] = array[i];
pr_debug("lane %u polarity %sinverted",
i, array[i] ? "" : "not ");
}
} else {
pr_debug("no lane polarities defined, assuming not inverted\n");
} }
if (!fwnode_property_read_u32(fwnode, "clock-lanes", &v)) { if (!fwnode_property_read_u32(fwnode, "clock-lanes", &v)) {
...@@ -121,6 +111,22 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode, ...@@ -121,6 +111,22 @@ static int v4l2_fwnode_endpoint_parse_csi2_bus(struct fwnode_handle *fwnode,
bus->flags = flags; bus->flags = flags;
vep->bus_type = V4L2_MBUS_CSI2_DPHY; vep->bus_type = V4L2_MBUS_CSI2_DPHY;
bus->num_data_lanes = num_data_lanes; bus->num_data_lanes = num_data_lanes;
for (i = 0; i < num_data_lanes; i++)
bus->data_lanes[i] = array[i];
if (have_lane_polarities) {
fwnode_property_read_u32_array(fwnode,
"lane-polarities", array,
1 + num_data_lanes);
for (i = 0; i < 1 + num_data_lanes; i++) {
bus->lane_polarities[i] = array[i];
pr_debug("lane %u polarity %sinverted",
i, array[i] ? "" : "not ");
}
} else {
pr_debug("no lane polarities defined, assuming not inverted\n");
}
} }
return 0; return 0;
......
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