On 12/2/26 10:09, Qianhui Xu wrote:
prepare() only undid the power-up when the initialisation sequence
failed. Failures of the picture parameter set, the compression mode
commands or the backlight enable were ignored, leaving the panel powered
with a wrong state and -- for the backlight -- with the error swallowed.
Use a single power_off label for all error paths and also check
dsi_ctx.accum_err after the batched MIPI writes, as those helpers only
record their error there.

Fixes: 75a5dbd1f4f7 ("drm/panel: Add Novatek NT36536 panel driver")
Cc: <[email protected]>
Signed-off-by: Qianhui Xu <[email protected]>
---
  drivers/gpu/drm/panel/panel-novatek-nt36536.c | 19 ++++++++++++++-----
  1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-novatek-nt36536.c 
b/drivers/gpu/drm/panel/panel-novatek-nt36536.c
index 7aa26796e2a90..e372e346d8b77 100644
--- a/drivers/gpu/drm/panel/panel-novatek-nt36536.c
+++ b/drivers/gpu/drm/panel/panel-novatek-nt36536.c
@@ -100,18 +100,27 @@ static int novatek_prepare(struct drm_panel *panel)
        ret = ctx->desc->init_sequence(&dsi_ctx);
        if (ret < 0) {
                dev_err(dev, "Failed to initialize panel: %d\n", ret);
-               gpiod_set_value_cansleep(ctx->reset_gpio, 1);
-               regulator_bulk_disable(ARRAY_SIZE(novatek_supplies),
-                                      ctx->supplies);
-               return ret;
+               goto power_off;
        }
drm_dsc_pps_payload_pack(&pps, &ctx->dsc);
        mipi_dsi_picture_parameter_set_multi(&dsi_ctx, &pps);
        mipi_dsi_compression_mode_multi(&dsi_ctx, true);
        mipi_dsi_msleep(&dsi_ctx, 28);
+       ret = dsi_ctx.accum_err;
+       if (ret)
+               goto power_off;
+
+       ret = backlight_enable(ctx->backlight);
+       if (ret)
+               goto power_off;
+
+       return 0;
- return backlight_enable(ctx->backlight);
+power_off:
+       gpiod_set_value_cansleep(ctx->reset_gpio, 1);
+       regulator_bulk_disable(ARRAY_SIZE(novatek_supplies), ctx->supplies);
+       return ret;
  }
static int novatek_off(struct mipi_dsi_multi_context *dsi_ctx)

Reviewed-by: Neil Armstrong <[email protected]>

Thanks,
Neil

Reply via email to