If enabling tearing mode or exiting sleep mode fails after the
regulator is enabled, s6d16d0_prepare() returns without asserting
reset or disabling the supply. Since the DRM panel core leaves the
panel unprepared, a later unprepare call skips the driver callback
and the supply remains enabled.

Assert reset and disable the supply before returning the DSI command error.

Fixes: ac1d6d74884e ("drm/panel: Add driver for Samsung S6D16D0 panel")
Assisted-by: Codex:gpt-5
Signed-off-by: Laxman Acharya Padhya <[email protected]>
---
Changes in v2:
- Resend as plain text with git-send-email.
- Correct author, sign-off, and recipient formatting.
- No code changes.

 drivers/gpu/drm/panel/panel-samsung-s6d16d0.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-samsung-s6d16d0.c 
b/drivers/gpu/drm/panel/panel-samsung-s6d16d0.c
index ba1a02000..04e19b5f2 100644
--- a/drivers/gpu/drm/panel/panel-samsung-s6d16d0.c
+++ b/drivers/gpu/drm/panel/panel-samsung-s6d16d0.c
@@ -89,16 +89,22 @@ static int s6d16d0_prepare(struct drm_panel *panel)
                                       MIPI_DSI_DCS_TEAR_MODE_VBLANK);
        if (ret) {
                dev_err(s6->dev, "failed to enable vblank TE (%d)\n", ret);
-               return ret;
+               goto err_power_off;
        }
        /* Exit sleep mode and power on */
        ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
        if (ret) {
                dev_err(s6->dev, "failed to exit sleep mode (%d)\n", ret);
-               return ret;
+               goto err_power_off;
        }
 
        return 0;
+
+err_power_off:
+       gpiod_set_value_cansleep(s6->reset_gpio, 1);
+       regulator_disable(s6->supply);
+
+       return ret;
 }
 
 static int s6d16d0_enable(struct drm_panel *panel)
-- 
2.51.2

Reply via email to