drm/amdgpu: Remove a lot of unnecessary ternary operators
authorRuan Jinjie <ruanjinjie@huawei.com>
Fri, 4 Aug 2023 02:46:48 +0000 (10:46 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 9 Aug 2023 13:39:56 +0000 (09:39 -0400)
There are many ternary operators, the true or false judgement
of which is unnecessary in C language semantics.

Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
13 files changed:
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
drivers/gpu/drm/amd/amdgpu/jpeg_v3_0.c
drivers/gpu/drm/amd/amdgpu/jpeg_v4_0.c
drivers/gpu/drm/amd/amdgpu/jpeg_v4_0_3.c
drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c
drivers/gpu/drm/amd/display/dc/dce/dce_link_encoder.c
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_powertune.c
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c
drivers/gpu/drm/amd/pm/powerplay/smumgr/polaris10_smumgr.c
drivers/gpu/drm/amd/pm/powerplay/smumgr/vegam_smumgr.c

index b582b83c4984fa7d833e1d21ce6800d5c1c78a47..38ccec913f0097772c6facd1a73b5cbeeca8287e 100644 (file)
@@ -460,7 +460,7 @@ bool amdgpu_get_bios(struct amdgpu_device *adev)
        return false;
 
 success:
-       adev->is_atom_fw = (adev->asic_type >= CHIP_VEGA10) ? true : false;
+       adev->is_atom_fw = adev->asic_type >= CHIP_VEGA10;
        return true;
 }
 
index 79791379fc2b09b9b77221f8710fa92484de8428..df4440c21bbf4f5911ed311668be71e22efab6ca 100644 (file)
@@ -479,7 +479,7 @@ static int jpeg_v3_0_set_clockgating_state(void *handle,
                                          enum amd_clockgating_state state)
 {
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-       bool enable = (state == AMD_CG_STATE_GATE) ? true : false;
+       bool enable = state == AMD_CG_STATE_GATE;
 
        if (enable) {
                if (!jpeg_v3_0_is_idle(handle))
index a707d407fbd0d28edc26b2e5b2d8ba0cf332ee62..3eb3dcd56b579129e6b566da20c3c8a88ea06f1f 100644 (file)
@@ -626,7 +626,7 @@ static int jpeg_v4_0_set_clockgating_state(void *handle,
                                          enum amd_clockgating_state state)
 {
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-       bool enable = (state == AMD_CG_STATE_GATE) ? true : false;
+       bool enable = state == AMD_CG_STATE_GATE;
 
        if (enable) {
                if (!jpeg_v4_0_is_idle(handle))
index ce2b22f7e4e4b8bf21860e5b4d724bcc16b2db7f..153731d6ce8b2c0317569b9e9a85df170ca92365 100644 (file)
@@ -785,7 +785,7 @@ static int jpeg_v4_0_3_set_clockgating_state(void *handle,
                                          enum amd_clockgating_state state)
 {
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-       bool enable = (state == AMD_CG_STATE_GATE) ? true : false;
+       bool enable = state == AMD_CG_STATE_GATE;
        int i;
 
        for (i = 0; i < adev->jpeg.num_jpeg_inst; ++i) {
index b76ba21b5a896c9a5ca8614c73b685064527b0ff..9b662b105cc13e42f1c261ce364fdbb64c352c9f 100644 (file)
@@ -2095,7 +2095,7 @@ static int vcn_v3_0_set_clockgating_state(void *handle,
                                          enum amd_clockgating_state state)
 {
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-       bool enable = (state == AMD_CG_STATE_GATE) ? true : false;
+       bool enable = state == AMD_CG_STATE_GATE;
        int i;
 
        for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
index 6089c7deba8ac810762c833ed49ade0e1eb80998..7c486745bece6f699ac0411494bcaefb30f62b2a 100644 (file)
@@ -1918,7 +1918,7 @@ static int vcn_v4_0_wait_for_idle(void *handle)
 static int vcn_v4_0_set_clockgating_state(void *handle, enum amd_clockgating_state state)
 {
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-       bool enable = (state == AMD_CG_STATE_GATE) ? true : false;
+       bool enable = state == AMD_CG_STATE_GATE;
        int i;
 
        for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
index 550ac040b4be85b06af2bebe5d556ea413fc5645..e62472e6e7b3e848cd698834bf50c9a97252c326 100644 (file)
@@ -1287,7 +1287,7 @@ static int vcn_v4_0_3_set_clockgating_state(void *handle,
                                          enum amd_clockgating_state state)
 {
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-       bool enable = (state == AMD_CG_STATE_GATE) ? true : false;
+       bool enable = state == AMD_CG_STATE_GATE;
        int i;
 
        for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
index bf2f620aeb66443ba2cfcb53aac02994f111f806..136bd93c3b655400926feb28ada3b2e7036c8838 100644 (file)
@@ -941,9 +941,7 @@ bool dce110_link_encoder_validate_output_with_stream(
        break;
        case SIGNAL_TYPE_EDP:
        case SIGNAL_TYPE_LVDS:
-               is_valid =
-                       (stream->timing.
-                               pixel_encoding == PIXEL_ENCODING_RGB) ? true : false;
+               is_valid = stream->timing.pixel_encoding == PIXEL_ENCODING_RGB;
        break;
        case SIGNAL_TYPE_VIRTUAL:
                is_valid = true;
index 1cb40226449779d004d9cf2fdfae8e7f7f1364c0..3d61489209dd450f5a0258915cb9ee7805e206a7 100644 (file)
@@ -904,7 +904,7 @@ static int smu7_setup_dpm_tables_v1(struct pp_hwmgr *hwmgr)
                                        dep_sclk_table->entries[i].clk;
 
                        data->dpm_table.sclk_table.dpm_levels[data->dpm_table.sclk_table.count].enabled =
-                                       (i == 0) ? true : false;
+                                       i == 0;
                        data->dpm_table.sclk_table.count++;
                }
        }
@@ -919,7 +919,7 @@ static int smu7_setup_dpm_tables_v1(struct pp_hwmgr *hwmgr)
                        data->dpm_table.mclk_table.dpm_levels[data->dpm_table.mclk_table.count].value =
                                                        dep_mclk_table->entries[i].clk;
                        data->dpm_table.mclk_table.dpm_levels[data->dpm_table.mclk_table.count].enabled =
-                                                       (i == 0) ? true : false;
+                                                       i == 0;
                        data->dpm_table.mclk_table.count++;
                }
        }
index 21be23ec3c79e2f446aa4139fdf965ac252c2019..d6eeef3c58f732b36d2088c1bf281e4aa346d383 100644 (file)
@@ -1103,7 +1103,7 @@ int smu7_enable_smc_cac(struct pp_hwmgr *hwmgr)
                PP_ASSERT_WITH_CODE((0 == smc_result),
                                "Failed to enable CAC in SMC.", result = -1);
 
-               data->cac_enabled = (0 == smc_result) ? true : false;
+               data->cac_enabled = smc_result == 0;
        }
        return result;
 }
index c51dd4c74fe9db3fc52121a042f570a94e1d9e59..52ae6fa2d2a6d0f6d7fe4bb2b484d5e5fb754b7a 100644 (file)
@@ -1375,8 +1375,7 @@ static int vega10_setup_default_dpm_tables(struct pp_hwmgr *hwmgr)
                                                dep_mm_table->entries[i].eclk) {
                        dpm_table->dpm_levels[dpm_table->count].value =
                                        dep_mm_table->entries[i].eclk;
-                       dpm_table->dpm_levels[dpm_table->count].enabled =
-                                       (i == 0) ? true : false;
+                       dpm_table->dpm_levels[dpm_table->count].enabled = i == 0;
                        dpm_table->count++;
                }
        }
@@ -1391,8 +1390,7 @@ static int vega10_setup_default_dpm_tables(struct pp_hwmgr *hwmgr)
                                                dep_mm_table->entries[i].vclk) {
                        dpm_table->dpm_levels[dpm_table->count].value =
                                        dep_mm_table->entries[i].vclk;
-                       dpm_table->dpm_levels[dpm_table->count].enabled =
-                                       (i == 0) ? true : false;
+                       dpm_table->dpm_levels[dpm_table->count].enabled = i == 0;
                        dpm_table->count++;
                }
        }
@@ -1405,8 +1403,7 @@ static int vega10_setup_default_dpm_tables(struct pp_hwmgr *hwmgr)
                                                dep_mm_table->entries[i].dclk) {
                        dpm_table->dpm_levels[dpm_table->count].value =
                                        dep_mm_table->entries[i].dclk;
-                       dpm_table->dpm_levels[dpm_table->count].enabled =
-                                       (i == 0) ? true : false;
+                       dpm_table->dpm_levels[dpm_table->count].enabled = i == 0;
                        dpm_table->count++;
                }
        }
index e7ed2a7adf8f7b98c8ec3dbe8f6534371e706524..ff6b563ecbf5147443d87b5d15a54600ea7e2403 100644 (file)
@@ -1888,7 +1888,7 @@ static int polaris10_populate_avfs_parameters(struct pp_hwmgr *hwmgr)
                                                (avfs_params.ucEnableGB_VDROOP_TABLE_CKSOFF << BTCGB1_Vdroop_Enable_SHIFT) |
                                                (avfs_params.ucEnableGB_FUSE_TABLE_CKSON << AVFSGB0_Vdroop_Enable_SHIFT) |
                                                (avfs_params.ucEnableGB_FUSE_TABLE_CKSOFF << AVFSGB1_Vdroop_Enable_SHIFT);
-               data->apply_avfs_cks_off_voltage = (avfs_params.ucEnableApplyAVFS_CKS_OFF_Voltage == 1) ? true : false;
+               data->apply_avfs_cks_off_voltage = avfs_params.ucEnableApplyAVFS_CKS_OFF_Voltage == 1;
        }
        return result;
 }
index 7d024d3facef047715d0d61c2b2d51d89b3fc1af..34c9f59b889a15dee4a219cc287155ca16b986d5 100644 (file)
@@ -295,9 +295,8 @@ static int vegam_process_firmware_header(struct pp_hwmgr *hwmgr)
 
 static bool vegam_is_dpm_running(struct pp_hwmgr *hwmgr)
 {
-       return (1 == PHM_READ_INDIRECT_FIELD(hwmgr->device,
-                       CGS_IND_REG__SMC, FEATURE_STATUS, VOLTAGE_CONTROLLER_ON))
-                       ? true : false;
+       return 1 == PHM_READ_INDIRECT_FIELD(hwmgr->device,
+                       CGS_IND_REG__SMC, FEATURE_STATUS, VOLTAGE_CONTROLLER_ON);
 }
 
 static uint32_t vegam_get_mac_definition(uint32_t value)
@@ -1660,7 +1659,7 @@ static int vegam_populate_avfs_parameters(struct pp_hwmgr *hwmgr)
                                (avfs_params.ucEnableGB_FUSE_TABLE_CKSON << AVFSGB0_Vdroop_Enable_SHIFT) |
                                (avfs_params.ucEnableGB_FUSE_TABLE_CKSOFF << AVFSGB1_Vdroop_Enable_SHIFT);
                data->apply_avfs_cks_off_voltage =
-                               (avfs_params.ucEnableApplyAVFS_CKS_OFF_Voltage == 1) ? true : false;
+                               avfs_params.ucEnableApplyAVFS_CKS_OFF_Voltage == 1;
        }
        return result;
 }