Besides using state->dev to access the nouveau_drm device again, there
should be no functional changes here.

Fixes: f575f2bdb6c3 ("drm/nouveau/kms/nv50-: Remove (nv_encoder->crtc) checks 
in ->disable callbacks")
Cc: <[email protected]> # v5.12+
Signed-off-by: Lyude Paul <[email protected]>
---
 drivers/gpu/drm/nouveau/dispnv50/disp.c | 39 +++++++++++++++++--------
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c 
b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index 2c66e480b5116..a885394f7cb92 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -1561,24 +1561,39 @@ nv50_sor_update(struct nouveau_encoder *nv_encoder, u8 
head,
  * the panel backlight has been shut off? Intel doesn't seem to do this, and 
uses a
  * fixed time delay from the vbios…
  */
+#ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT
+static inline void
+nv50_sor_atomic_disable_backlight(struct nouveau_drm *drm,
+                                 struct nouveau_encoder *nv_encoder,
+                                 struct drm_atomic_commit *state)
+{
+       struct nouveau_connector *nv_connector;
+       struct nouveau_backlight *backlight;
+       int ret;
+
+       nv_connector = nv50_outp_get_old_connector(state, nv_encoder);
+       if (drm_WARN_ON(drm->dev, !nv_connector))
+               return;
+       backlight = nv_connector->backlight;
+
+       if (!backlight || !backlight->uses_dpcd)
+               return;
+
+       ret = drm_edp_backlight_disable(&nv_connector->aux, 
&backlight->edp_info);
+       if (ret < 0)
+               NV_ERROR(drm, "Failed to disable backlight on 
[CONNECTOR:%d:%s]: %d\n",
+                        nv_connector->base.base.id, nv_connector->base.name, 
ret);
+}
+#endif
+
 static void
 nv50_sor_atomic_disable(struct drm_encoder *encoder, struct drm_atomic_commit 
*state)
 {
        struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
        struct nv50_head *head = nv50_head(nv_encoder->crtc);
-#ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT
-       struct nouveau_connector *nv_connector = 
nv50_outp_get_old_connector(state, nv_encoder);
-       struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev);
-       struct nouveau_backlight *backlight = nv_connector->backlight;
-       struct drm_dp_aux *aux = &nv_connector->aux;
-       int ret;
 
-       if (backlight && backlight->uses_dpcd) {
-               ret = drm_edp_backlight_disable(aux, &backlight->edp_info);
-               if (ret < 0)
-                       NV_ERROR(drm, "Failed to disable backlight on 
[CONNECTOR:%d:%s]: %d\n",
-                                nv_connector->base.base.id, 
nv_connector->base.name, ret);
-       }
+#ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT
+       nv50_sor_atomic_disable_backlight(nouveau_drm(state->dev), nv_encoder, 
state);
 #endif
 
        if (nv_encoder->dcb->type == DCB_OUTPUT_TMDS && 
nv_encoder->hdmi.enabled) {
-- 
2.55.0

Reply via email to