Replace the deprecated MIPI DSI DCS helpers with their _multi variants,
as suggested in Documentation/gpu/todo.rst. Also convert
mipi_dsi_dcs_write_buffer() for consistency.

In prepare(), the first failed command prevents subsequent DSI transfers
and its error is returned, as before. The new helper also logs the error.

In unprepare(), clear accum_err between commands so that ENTER_SLEEP_MODE
is still attempted if SET_DISPLAY_OFF fails, preserving the original
error handling behavior.

In disable(), ignore SET_DISPLAY_OFF errors to allow drm_panel_disable()
to clear panel->enabled, avoiding a stale enabled state after the panel
is powered off. This follows commit 00efe8a68565 ("drm/panel:
ronbo-rb070d30: Ignore DCS errors in disable()"). Command failures
remain logged by the helper.

Signed-off-by: Hsieh Hung-En <[email protected]>
---
 .../drm/panel/panel-feiyang-fy07024di26a30d.c | 35 +++++++++++--------
 1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-feiyang-fy07024di26a30d.c 
b/drivers/gpu/drm/panel/panel-feiyang-fy07024di26a30d.c
index c1d8ca5ca6e1..24934b9d430b 100644
--- a/drivers/gpu/drm/panel/panel-feiyang-fy07024di26a30d.c
+++ b/drivers/gpu/drm/panel/panel-feiyang-fy07024di26a30d.c
@@ -46,7 +46,7 @@ static const struct feiyang_init_cmd feiyang_init_cmds[] = {
 static int feiyang_prepare(struct drm_panel *panel)
 {
        struct feiyang *ctx = panel_to_feiyang(panel);
-       struct mipi_dsi_device *dsi = ctx->dsi;
+       struct mipi_dsi_multi_context dsi_ctx = { .dsi = ctx->dsi };
        unsigned int i;
        int ret;
 
@@ -81,44 +81,51 @@ static int feiyang_prepare(struct drm_panel *panel)
                const struct feiyang_init_cmd *cmd =
                                                &feiyang_init_cmds[i];
 
-               ret = mipi_dsi_dcs_write_buffer(dsi, cmd->data,
+               mipi_dsi_dcs_write_buffer_multi(&dsi_ctx, cmd->data,
                                                FEIYANG_INIT_CMD_LEN);
-               if (ret < 0)
-                       return ret;
        }
 
-       return 0;
+       return dsi_ctx.accum_err;
 }
 
 static int feiyang_enable(struct drm_panel *panel)
 {
        struct feiyang *ctx = panel_to_feiyang(panel);
+       struct mipi_dsi_multi_context dsi_ctx = { .dsi = ctx->dsi };
 
        /* T12 (video & logic signal rise + backlight rise) T12 >= 200ms */
        msleep(200);
 
-       return mipi_dsi_dcs_set_display_on(ctx->dsi);
+       mipi_dsi_dcs_set_display_on_multi(&dsi_ctx);
+
+       return dsi_ctx.accum_err;
 }
 
 static int feiyang_disable(struct drm_panel *panel)
 {
        struct feiyang *ctx = panel_to_feiyang(panel);
+       struct mipi_dsi_multi_context dsi_ctx = { .dsi = ctx->dsi };
 
-       return mipi_dsi_dcs_set_display_off(ctx->dsi);
+       mipi_dsi_dcs_set_display_off_multi(&dsi_ctx);
+
+       /*
+        * Returning an error would leave panel->enabled set, causing the
+        * next enable to be skipped even after unprepare powers off the panel.
+        * The helper above already logs any command failure.
+        */
+       return 0;
 }
 
 static int feiyang_unprepare(struct drm_panel *panel)
 {
        struct feiyang *ctx = panel_to_feiyang(panel);
-       int ret;
+       struct mipi_dsi_multi_context dsi_ctx = { .dsi = ctx->dsi };
 
-       ret = mipi_dsi_dcs_set_display_off(ctx->dsi);
-       if (ret < 0)
-               dev_err(panel->dev, "failed to set display off: %d\n", ret);
+       mipi_dsi_dcs_set_display_off_multi(&dsi_ctx);
 
-       ret = mipi_dsi_dcs_enter_sleep_mode(ctx->dsi);
-       if (ret < 0)
-               dev_err(panel->dev, "failed to enter sleep mode: %d\n", ret);
+       /* Attempt to enter sleep mode even if display off failed. */
+       dsi_ctx.accum_err = 0;
+       mipi_dsi_dcs_enter_sleep_mode_multi(&dsi_ctx);
 
        /* T13 (backlight fall + video & logic signal fall) T13 >= 200ms */
        msleep(200);
-- 
2.43.0

Reply via email to