diff mbox series

[RFC,09/15] drm: rcar-du: dsi: Simplify DT parsing

Message ID 20210623034656.10316-10-laurent.pinchart+renesas@ideasonboard.com (mailing list archive)
State New
Delegated to: Kieran Bingham
Headers show
Series R-Car V3U: DSI encoder driver | expand

Commit Message

Laurent Pinchart June 23, 2021, 3:46 a.m. UTC
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c | 41 +++++++++----------------
 1 file changed, 14 insertions(+), 27 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
index a6bb7f25164b..d16bf50e8acb 100644
--- a/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
+++ b/drivers/gpu/drm/rcar-du/rcar_mipi_dsi.c
@@ -678,40 +678,27 @@  static const struct mipi_dsi_host_ops rcar_mipi_dsi_host_ops = {
 
 static int rcar_mipi_dsi_parse_dt(struct rcar_mipi_dsi *dsi)
 {
-	struct device_node *local_output = NULL;
-	struct property *prop;
-	int ret = 0;
-	int len, num_lanes;
+	struct device_node *ep;
+	u32 data_lanes[4];
+	int ret;
 
-	local_output = of_graph_get_endpoint_by_regs(dsi->dev->of_node,
-						     1, 0);
-	if (!local_output) {
+	ep = of_graph_get_endpoint_by_regs(dsi->dev->of_node, 1, 0);
+	if (!ep) {
 		dev_dbg(dsi->dev, "unconnected port@1\n");
-		ret = -ENODEV;
-		goto done;
+		return -ENODEV;
 	}
 
-	/* Get lanes information */
-	prop = of_find_property(local_output, "data-lanes", &len);
-	if (!prop) {
-		dsi->num_data_lanes = 4;
-		dev_dbg(dsi->dev,
-			"failed to find data lane information, using default\n");
-		goto done;
-	}
-
-	num_lanes = len / sizeof(u32);
+	ret = of_property_read_variable_u32_array(ep, "data-lanes", data_lanes,
+						  1, 4);
+	of_node_put(ep);
 
-	if (num_lanes < 1 || num_lanes > 4) {
-		dev_err(dsi->dev, "data lanes definition is not correct\n");
-		return -EINVAL;
+	if (ret < 0) {
+		dev_err(dsi->dev, "missing or invalid data-lanes property\n");
+		return -ENODEV;
 	}
 
-	dsi->num_data_lanes = num_lanes;
-done:
-	of_node_put(local_output);
-
-	return ret;
+	dsi->num_data_lanes = ret;
+	return 0;
 }
 
 static struct clk *rcar_mipi_dsi_get_clock(struct rcar_mipi_dsi *dsi,