[PATCH 3/4] drm/panel: novatek-nt36536: power off on any prepare failure

From: Qianhui Xu

Date: Tue Dec 01 2026 - 04:15:45 EST


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.

Signed-off-by: Qianhui Xu <xiaqinghuan@xxxxxxxxxxxxxxxx>
---
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 fb77ae437bbc8..88a003f5a9441 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)