The mipi_dsi_dcs_*() functions used by this driver are deprecated in favour of their _multi() counterparts, as noted in Documentation/gpu/todo.rst. The _multi() variants record the first error in a context structure and skip subsequent calls once an error is set, removing the need to check the return value after each command. They also log failures internally, making the per-call dev_err() calls redundant.
Convert prepare() and unprepare() to use the _multi() equivalents. In prepare(), use mipi_dsi_msleep() and mipi_dsi_usleep_range() instead of plain msleep()/usleep_range() for delays between DSI commands, so they are skipped on prior error since the function will clean up via the existing disable_vdd label anyway. In unprepare(), keep plain msleep() and usleep_range() since the hardware delays must execute regardless of any prior DSI error. The original code logged a set_display_off() failure and still attempted enter_sleep_mode(), so clear accum_err after set_display_off_multi() to keep that behaviour. This also fixes a bug where a failure in enter_sleep_mode would return early, skipping the post-sleep delay, reset GPIO assertion, and regulator disable, leaving the panel stuck in a prepared state. Because drm_panel_unprepare() does not clear panel->prepared when the callback returns an error, drm_panel_prepare() would return early on the next call, leaving the panel unable to be re-initialised. Cc: Chris Morgan <[email protected]> Signed-off-by: Akash Sukhavasi <[email protected]> --- Compile tested only, no hardware available. checkpatch and a W=1 build are clean. --- drivers/gpu/drm/panel/panel-newvision-nv3051d.c | 36 +++++++++---------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-newvision-nv3051d.c b/drivers/gpu/drm/panel/panel-newvision-nv3051d.c index 22560384e48e..7dc25102a773 100644 --- a/drivers/gpu/drm/panel/panel-newvision-nv3051d.c +++ b/drivers/gpu/drm/panel/panel-newvision-nv3051d.c @@ -247,19 +247,14 @@ static int panel_nv3051d_unprepare(struct drm_panel *panel) { struct panel_nv3051d *ctx = panel_to_panelnv3051d(panel); struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); - int ret; - - ret = mipi_dsi_dcs_set_display_off(dsi); - if (ret < 0) - dev_err(ctx->dev, "failed to set display off: %d\n", ret); + struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi }; + mipi_dsi_dcs_set_display_off_multi(&dsi_ctx); + /* Reset error to continue power-down sequence even if display off failed */ + dsi_ctx.accum_err = 0; msleep(20); - - ret = mipi_dsi_dcs_enter_sleep_mode(dsi); - if (ret < 0) { - dev_err(ctx->dev, "failed to enter sleep mode: %d\n", ret); - return ret; - } + /* Enter sleep mode; error does not prevent power-off */ + mipi_dsi_dcs_enter_sleep_mode_multi(&dsi_ctx); usleep_range(10000, 15000); @@ -274,6 +269,7 @@ static int panel_nv3051d_prepare(struct drm_panel *panel) { struct panel_nv3051d *ctx = panel_to_panelnv3051d(panel); struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); + struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi }; int ret; dev_dbg(ctx->dev, "Resetting the panel\n"); @@ -295,22 +291,16 @@ static int panel_nv3051d_prepare(struct drm_panel *panel) goto disable_vdd; } - ret = mipi_dsi_dcs_exit_sleep_mode(dsi); - if (ret < 0) { - dev_err(ctx->dev, "Failed to exit sleep mode: %d\n", ret); - goto disable_vdd; - } - - msleep(200); + mipi_dsi_dcs_exit_sleep_mode_multi(&dsi_ctx); + mipi_dsi_msleep(&dsi_ctx, 200); + mipi_dsi_dcs_set_display_on_multi(&dsi_ctx); + mipi_dsi_usleep_range(&dsi_ctx, 10000, 15000); - ret = mipi_dsi_dcs_set_display_on(dsi); - if (ret < 0) { - dev_err(ctx->dev, "Failed to set display on: %d\n", ret); + if (dsi_ctx.accum_err) { + ret = dsi_ctx.accum_err; goto disable_vdd; } - usleep_range(10000, 15000); - return 0; disable_vdd: -- 2.56.0
