From 23734fc29585cfcb03152875bd7805979bf82dd4 Mon Sep 17 00:00:00 2001 From: Shashank Babu Chinta Venkata Date: Wed, 3 Feb 2021 00:22:45 -0800 Subject: [PATCH] disp: msm: dsi: reorder resource validation in probe Reorder resource validation to report probe deferral appropriately. Change-Id: I63aab1b3282bda24dba2b84906564de290345fdd Signed-off-by: Shashank Babu Chinta Venkata --- msm/dsi/dsi_display.c | 62 +++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 23 deletions(-) diff --git a/msm/dsi/dsi_display.c b/msm/dsi/dsi_display.c index 288ea6182b..7afa7407f3 100644 --- a/msm/dsi/dsi_display.c +++ b/msm/dsi/dsi_display.c @@ -4020,7 +4020,7 @@ error: return rc; } -static int dsi_display_res_init(struct dsi_display *display) +static int dsi_display_validate_resources(struct dsi_display *display) { int rc = 0; int i; @@ -4033,7 +4033,7 @@ static int dsi_display_res_init(struct dsi_display *display) rc = PTR_ERR(ctrl->ctrl); DSI_ERR("failed to get dsi controller, rc=%d\n", rc); ctrl->ctrl = NULL; - goto error_ctrl_put; + goto error; } ctrl->phy = dsi_phy_get(ctrl->phy_of_node); @@ -4042,9 +4042,24 @@ static int dsi_display_res_init(struct dsi_display *display) DSI_ERR("failed to get phy controller, rc=%d\n", rc); dsi_ctrl_put(ctrl->ctrl); ctrl->phy = NULL; - goto error_ctrl_put; + goto error; } } + return rc; + +error: + for (i = i - 1; i >= 0; i--) { + ctrl = &display->ctrl[i]; + dsi_ctrl_put(ctrl->ctrl); + dsi_phy_put(ctrl->phy); + } + return -EPROBE_DEFER; +} + +static int dsi_display_res_init(struct dsi_display *display) +{ + int rc = 0; + int i; display->panel = dsi_panel_get(&display->pdev->dev, display->panel_node, @@ -4056,7 +4071,7 @@ static int dsi_display_res_init(struct dsi_display *display) rc = PTR_ERR(display->panel); DSI_ERR("failed to get panel, rc=%d\n", rc); display->panel = NULL; - goto error_ctrl_put; + goto error; } display_for_each_ctrl(i, display) { @@ -4071,13 +4086,13 @@ static int dsi_display_res_init(struct dsi_display *display) rc = dsi_display_parse_lane_map(display); if (rc) { DSI_ERR("Lane map not found, rc=%d\n", rc); - goto error_ctrl_put; + goto error; } rc = dsi_display_clocks_init(display); if (rc) { DSI_ERR("Failed to parse clock data, rc=%d\n", rc); - goto error_ctrl_put; + goto error; } /** @@ -4088,14 +4103,7 @@ static int dsi_display_res_init(struct dsi_display *display) display->is_active = false; else display->is_active = true; - - return 0; -error_ctrl_put: - for (i = i - 1; i >= 0; i--) { - ctrl = &display->ctrl[i]; - dsi_ctrl_put(ctrl->ctrl); - dsi_phy_put(ctrl->phy); - } +error: return rc; } @@ -5078,12 +5086,6 @@ static int _dsi_display_dev_init(struct dsi_display *display) display->parser, display->fw->data, display->fw->size); - rc = dsi_display_parse_dt(display); - if (rc) { - DSI_ERR("[%s] failed to parse dt, rc=%d\n", display->name, rc); - goto error; - } - rc = dsi_display_res_init(display); if (rc) { DSI_ERR("[%s] failed to initialize resources, rc=%d\n", @@ -5637,8 +5639,6 @@ static int dsi_display_init(struct dsi_display *display) int rc = 0; struct platform_device *pdev = display->pdev; - mutex_init(&display->display_lock); - rc = _dsi_display_dev_init(display); if (rc) { DSI_ERR("device init failed, rc=%d\n", rc); @@ -5720,6 +5720,7 @@ int dsi_display_dev_probe(struct platform_device *pdev) rc = -ENOMEM; goto end; } + mutex_init(&display->display_lock); display->dma_cmd_workq = create_singlethread_workqueue( "dsi_dma_cmd_workq"); @@ -5777,6 +5778,19 @@ int dsi_display_dev_probe(struct platform_device *pdev) platform_set_drvdata(pdev, display); + rc = dsi_display_parse_dt(display); + if (rc) { + DSI_ERR("[%s] failed to parse dt, rc=%d\n", display->name, rc); + goto end; + } + + rc = dsi_display_validate_resources(display); + if (rc) { + DSI_ERR("[%s] needed resources not probed yet, rc=%d\n", + display->name, rc); + goto end; + } + /* initialize display in firmware callback */ if (!boot_disp->boot_disp_en && IS_ENABLED(CONFIG_DSI_PARSER) && @@ -5802,8 +5816,10 @@ int dsi_display_dev_probe(struct platform_device *pdev) return 0; end: - if (display) + if (display) { + mutex_destroy(&display->display_lock); devm_kfree(&pdev->dev, display); + } return rc; }