The variable `pm_suspend_target_state` is conditionally defined only when
`CONFIG_SUSPEND` is enabled (see `include/linux/suspend.h`). Directly
referencing it without guarding by `#ifdef CONFIG_SUSPEND` causes build
failures when suspend functionality is disabled (e.g., `CONFIG_SUSPEND=n`).

Reviewed-by: Lijo Lazar <[email protected]>
Signed-off-by: Perry Yuan <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 4f8632737574..d3b6518a65f1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -2588,6 +2588,7 @@ static int amdgpu_pmops_suspend(struct device *dev)
        else if (amdgpu_acpi_is_s3_active(adev))
                adev->in_s3 = true;
        if (!adev->in_s0ix && !adev->in_s3) {
+#if IS_ENABLED(CONFIG_SUSPEND)
                /* don't allow going deep first time followed by s2idle the 
next time */
                if (adev->last_suspend_state != PM_SUSPEND_ON &&
                    adev->last_suspend_state != pm_suspend_target_state) {
@@ -2595,11 +2596,14 @@ static int amdgpu_pmops_suspend(struct device *dev)
                                     pm_suspend_target_state);
                        return -EINVAL;
                }
+#endif
                return 0;
        }
 
+#if IS_ENABLED(CONFIG_SUSPEND)
        /* cache the state last used for suspend */
        adev->last_suspend_state = pm_suspend_target_state;
+#endif
 
        return amdgpu_device_suspend(drm_dev, true);
 }
-- 
2.34.1

Reply via email to