drm/amd/display: Change dc_set_power_state() to bool instead of int
authorMario Limonciello <mario.limonciello@amd.com>
Mon, 25 Sep 2023 17:57:47 +0000 (12:57 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 26 Sep 2023 21:00:23 +0000 (17:00 -0400)
DC code is reused by other OSes and so Linux return codes don't
make sense.  Change dc_set_power_state() to boolean and add a wrapper
dm_set_power_state() to return a Linux error code for the memory
allocation failure.

Suggested-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
drivers/gpu/drm/amd/display/dc/core/dc.c
drivers/gpu/drm/amd/display/dc/dc.h

index 3480a02af7979c720974ca0788ad75baa8456f7c..297a28843e3a98bf9e2617712f2c36e8b2ffb46a 100644 (file)
@@ -2638,6 +2638,11 @@ static void hpd_rx_irq_work_suspend(struct amdgpu_display_manager *dm)
        }
 }
 
+static int dm_set_power_state(struct dc *dc, enum dc_acpi_cm_power_state power_state)
+{
+       return dc_set_power_state(dc, power_state) ? 0 : -ENOMEM;
+}
+
 static int dm_suspend(void *handle)
 {
        struct amdgpu_device *adev = handle;
@@ -2671,7 +2676,7 @@ static int dm_suspend(void *handle)
 
        hpd_rx_irq_work_suspend(dm);
 
-       return dc_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D3);
+       return dm_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D3);
 }
 
 struct amdgpu_dm_connector *
@@ -2865,7 +2870,7 @@ static int dm_resume(void *handle)
                if (r)
                        DRM_ERROR("DMUB interface failed to initialize: status=%d\n", r);
 
-               r = dc_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D0);
+               r = dm_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D0);
                if (r)
                        return r;
 
@@ -2917,7 +2922,7 @@ static int dm_resume(void *handle)
        }
 
        /* power on hardware */
-       r = dc_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D0);
+       r = dm_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D0);
        if (r)
                return r;
 
index 3b060e08707d5386402f018f79123905a9bc81cc..cb3cb2db90eef99091b0f33d0dbde41501abd149 100644 (file)
@@ -4723,7 +4723,7 @@ void dc_power_down_on_boot(struct dc *dc)
                dc->hwss.power_down_on_boot(dc);
 }
 
-int dc_set_power_state(
+bool dc_set_power_state(
        struct dc *dc,
        enum dc_acpi_cm_power_state power_state)
 {
@@ -4731,7 +4731,7 @@ int dc_set_power_state(
        struct display_mode_lib *dml;
 
        if (!dc->current_state)
-               return 0;
+               return true;
 
        switch (power_state) {
        case DC_ACPI_CM_POWER_STATE_D0:
@@ -4758,7 +4758,7 @@ int dc_set_power_state(
 
                ASSERT(dml);
                if (!dml)
-                       return -ENOMEM;
+                       return false;
 
                /* Preserve refcount */
                refcount = dc->current_state->refcount;
@@ -4777,7 +4777,7 @@ int dc_set_power_state(
                break;
        }
 
-       return 0;
+       return true;
 }
 
 void dc_resume(struct dc *dc)
index eec4592c932888e49299c09862ad4941e3127087..5e7f606a4cfcdef02492e73c5eb4f37e13ef363f 100644 (file)
@@ -2283,7 +2283,7 @@ void dc_notify_vsync_int_state(struct dc *dc, struct dc_stream_state *stream, bo
 
 /* Power Interfaces */
 
-int dc_set_power_state(
+bool dc_set_power_state(
                struct dc *dc,
                enum dc_acpi_cm_power_state power_state);
 void dc_resume(struct dc *dc);