Re: [PATCH -next] drm: nouveau: fix disp.c build when NOUVEAU_BACKLIGHT is not enabled

From: Lyude Paul
Date: Thu Jul 15 2021 - 17:47:27 EST


Reviewed-by: Lyude Paul <lyude@xxxxxxxxxx>

On Wed, 2021-07-14 at 10:15 -0700, Randy Dunlap wrote:
> Fix build errors and warnings when
> # CONFIG_DRM_NOUVEAU_BACKLIGHT is not set
>
> ../drivers/gpu/drm/nouveau/dispnv50/disp.c: In function
> ‘nv50_sor_atomic_disable’:
> ../drivers/gpu/drm/nouveau/dispnv50/disp.c:1665:52: error: ‘struct
> nouveau_connector’ has no member named ‘backlight’
>   struct nouveau_backlight *backlight = nv_connector->backlight;
>                                                     ^~
> ../drivers/gpu/drm/nouveau/dispnv50/disp.c:1670:28: error: dereferencing
> pointer to incomplete type ‘struct nouveau_backlight’
>   if (backlight && backlight->uses_dpcd) {
>
> and then fix subsequent build warnings after the above are fixed:
>
> ../drivers/gpu/drm/nouveau/dispnv50/disp.c: In function
> ‘nv50_sor_atomic_disable’:
> ../drivers/gpu/drm/nouveau/dispnv50/disp.c:1669:6: warning: unused variable
> ‘ret’ [-Wunused-variable]
>   int ret;
>       ^~~
> ../drivers/gpu/drm/nouveau/dispnv50/disp.c:1662:22: warning: unused variable
> ‘drm’ [-Wunused-variable]
>   struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev);
>                       ^~~
>
> Fixes: 6eca310e8924 ("drm/nouveau/kms/nv50-: Add basic DPCD backlight
> support for nouveau")
> Signed-off-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
> Cc: Ben Skeggs <bskeggs@xxxxxxxxxx>
> Cc: dri-devel@xxxxxxxxxxxxxxxxxxxxx
> Cc: nouveau@xxxxxxxxxxxxxxxxxxxxx
> Cc: Lyude Paul <lyude@xxxxxxxxxx>
> ---
>  drivers/gpu/drm/nouveau/dispnv50/disp.c |    8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> --- linux-next-20210714.orig/drivers/gpu/drm/nouveau/dispnv50/disp.c
> +++ linux-next-20210714/drivers/gpu/drm/nouveau/dispnv50/disp.c
> @@ -1659,23 +1659,27 @@ static void
>  nv50_sor_atomic_disable(struct drm_encoder *encoder, struct
> drm_atomic_state *state)
>  {
>         struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
> -       struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev);
>         struct nouveau_crtc *nv_crtc = nouveau_crtc(nv_encoder->crtc);
>         struct nouveau_connector *nv_connector =
> nv50_outp_get_old_connector(state, nv_encoder);
> +#ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT
> +       struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev);
>         struct nouveau_backlight *backlight = nv_connector->backlight;
> +#endif
>         struct drm_dp_aux *aux = &nv_connector->aux;
>         int ret;
>         u8 pwr;
>  
> +#ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT
>         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);
>         }
> +#endif
>  
>         if (nv_encoder->dcb->type == DCB_OUTPUT_DP) {
> -               int ret = drm_dp_dpcd_readb(aux, DP_SET_POWER, &pwr);
> +               ret = drm_dp_dpcd_readb(aux, DP_SET_POWER, &pwr);
>  
>                 if (ret == 0) {
>                         pwr &= ~DP_SET_POWER_MASK;
>

--
Cheers,
Lyude Paul (she/her)
Software Engineer at Red Hat