Commit 3b780089 authored by Ruan Jinjie's avatar Ruan Jinjie Committed by Alex Deucher

drm/amdgpu: Remove a lot of unnecessary ternary operators

There are many ternary operators, the true or false judgement
of which is unnecessary in C language semantics.
Signed-off-by: default avatarRuan Jinjie <ruanjinjie@huawei.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 665fdce5
...@@ -460,7 +460,7 @@ bool amdgpu_get_bios(struct amdgpu_device *adev) ...@@ -460,7 +460,7 @@ bool amdgpu_get_bios(struct amdgpu_device *adev)
return false; return false;
success: success:
adev->is_atom_fw = (adev->asic_type >= CHIP_VEGA10) ? true : false; adev->is_atom_fw = adev->asic_type >= CHIP_VEGA10;
return true; return true;
} }
......
...@@ -479,7 +479,7 @@ static int jpeg_v3_0_set_clockgating_state(void *handle, ...@@ -479,7 +479,7 @@ static int jpeg_v3_0_set_clockgating_state(void *handle,
enum amd_clockgating_state state) enum amd_clockgating_state state)
{ {
struct amdgpu_device *adev = (struct amdgpu_device *)handle; 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 (enable) {
if (!jpeg_v3_0_is_idle(handle)) if (!jpeg_v3_0_is_idle(handle))
......
...@@ -626,7 +626,7 @@ static int jpeg_v4_0_set_clockgating_state(void *handle, ...@@ -626,7 +626,7 @@ static int jpeg_v4_0_set_clockgating_state(void *handle,
enum amd_clockgating_state state) enum amd_clockgating_state state)
{ {
struct amdgpu_device *adev = (struct amdgpu_device *)handle; 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 (enable) {
if (!jpeg_v4_0_is_idle(handle)) if (!jpeg_v4_0_is_idle(handle))
......
...@@ -785,7 +785,7 @@ static int jpeg_v4_0_3_set_clockgating_state(void *handle, ...@@ -785,7 +785,7 @@ static int jpeg_v4_0_3_set_clockgating_state(void *handle,
enum amd_clockgating_state state) enum amd_clockgating_state state)
{ {
struct amdgpu_device *adev = (struct amdgpu_device *)handle; 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; int i;
for (i = 0; i < adev->jpeg.num_jpeg_inst; ++i) { for (i = 0; i < adev->jpeg.num_jpeg_inst; ++i) {
......
...@@ -2095,7 +2095,7 @@ static int vcn_v3_0_set_clockgating_state(void *handle, ...@@ -2095,7 +2095,7 @@ static int vcn_v3_0_set_clockgating_state(void *handle,
enum amd_clockgating_state state) enum amd_clockgating_state state)
{ {
struct amdgpu_device *adev = (struct amdgpu_device *)handle; 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; int i;
for (i = 0; i < adev->vcn.num_vcn_inst; ++i) { for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
......
...@@ -1918,7 +1918,7 @@ static int vcn_v4_0_wait_for_idle(void *handle) ...@@ -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) static int vcn_v4_0_set_clockgating_state(void *handle, enum amd_clockgating_state state)
{ {
struct amdgpu_device *adev = (struct amdgpu_device *)handle; 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; int i;
for (i = 0; i < adev->vcn.num_vcn_inst; ++i) { for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
......
...@@ -1287,7 +1287,7 @@ static int vcn_v4_0_3_set_clockgating_state(void *handle, ...@@ -1287,7 +1287,7 @@ static int vcn_v4_0_3_set_clockgating_state(void *handle,
enum amd_clockgating_state state) enum amd_clockgating_state state)
{ {
struct amdgpu_device *adev = (struct amdgpu_device *)handle; 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; int i;
for (i = 0; i < adev->vcn.num_vcn_inst; ++i) { for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
......
...@@ -941,9 +941,7 @@ bool dce110_link_encoder_validate_output_with_stream( ...@@ -941,9 +941,7 @@ bool dce110_link_encoder_validate_output_with_stream(
break; break;
case SIGNAL_TYPE_EDP: case SIGNAL_TYPE_EDP:
case SIGNAL_TYPE_LVDS: case SIGNAL_TYPE_LVDS:
is_valid = is_valid = stream->timing.pixel_encoding == PIXEL_ENCODING_RGB;
(stream->timing.
pixel_encoding == PIXEL_ENCODING_RGB) ? true : false;
break; break;
case SIGNAL_TYPE_VIRTUAL: case SIGNAL_TYPE_VIRTUAL:
is_valid = true; is_valid = true;
......
...@@ -904,7 +904,7 @@ static int smu7_setup_dpm_tables_v1(struct pp_hwmgr *hwmgr) ...@@ -904,7 +904,7 @@ static int smu7_setup_dpm_tables_v1(struct pp_hwmgr *hwmgr)
dep_sclk_table->entries[i].clk; dep_sclk_table->entries[i].clk;
data->dpm_table.sclk_table.dpm_levels[data->dpm_table.sclk_table.count].enabled = 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++; data->dpm_table.sclk_table.count++;
} }
} }
...@@ -919,7 +919,7 @@ static int smu7_setup_dpm_tables_v1(struct pp_hwmgr *hwmgr) ...@@ -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 = data->dpm_table.mclk_table.dpm_levels[data->dpm_table.mclk_table.count].value =
dep_mclk_table->entries[i].clk; dep_mclk_table->entries[i].clk;
data->dpm_table.mclk_table.dpm_levels[data->dpm_table.mclk_table.count].enabled = 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++; data->dpm_table.mclk_table.count++;
} }
} }
......
...@@ -1103,7 +1103,7 @@ int smu7_enable_smc_cac(struct pp_hwmgr *hwmgr) ...@@ -1103,7 +1103,7 @@ int smu7_enable_smc_cac(struct pp_hwmgr *hwmgr)
PP_ASSERT_WITH_CODE((0 == smc_result), PP_ASSERT_WITH_CODE((0 == smc_result),
"Failed to enable CAC in SMC.", result = -1); "Failed to enable CAC in SMC.", result = -1);
data->cac_enabled = (0 == smc_result) ? true : false; data->cac_enabled = smc_result == 0;
} }
return result; return result;
} }
......
...@@ -1375,8 +1375,7 @@ static int vega10_setup_default_dpm_tables(struct pp_hwmgr *hwmgr) ...@@ -1375,8 +1375,7 @@ static int vega10_setup_default_dpm_tables(struct pp_hwmgr *hwmgr)
dep_mm_table->entries[i].eclk) { dep_mm_table->entries[i].eclk) {
dpm_table->dpm_levels[dpm_table->count].value = dpm_table->dpm_levels[dpm_table->count].value =
dep_mm_table->entries[i].eclk; dep_mm_table->entries[i].eclk;
dpm_table->dpm_levels[dpm_table->count].enabled = dpm_table->dpm_levels[dpm_table->count].enabled = i == 0;
(i == 0) ? true : false;
dpm_table->count++; dpm_table->count++;
} }
} }
...@@ -1391,8 +1390,7 @@ static int vega10_setup_default_dpm_tables(struct pp_hwmgr *hwmgr) ...@@ -1391,8 +1390,7 @@ static int vega10_setup_default_dpm_tables(struct pp_hwmgr *hwmgr)
dep_mm_table->entries[i].vclk) { dep_mm_table->entries[i].vclk) {
dpm_table->dpm_levels[dpm_table->count].value = dpm_table->dpm_levels[dpm_table->count].value =
dep_mm_table->entries[i].vclk; dep_mm_table->entries[i].vclk;
dpm_table->dpm_levels[dpm_table->count].enabled = dpm_table->dpm_levels[dpm_table->count].enabled = i == 0;
(i == 0) ? true : false;
dpm_table->count++; dpm_table->count++;
} }
} }
...@@ -1405,8 +1403,7 @@ static int vega10_setup_default_dpm_tables(struct pp_hwmgr *hwmgr) ...@@ -1405,8 +1403,7 @@ static int vega10_setup_default_dpm_tables(struct pp_hwmgr *hwmgr)
dep_mm_table->entries[i].dclk) { dep_mm_table->entries[i].dclk) {
dpm_table->dpm_levels[dpm_table->count].value = dpm_table->dpm_levels[dpm_table->count].value =
dep_mm_table->entries[i].dclk; dep_mm_table->entries[i].dclk;
dpm_table->dpm_levels[dpm_table->count].enabled = dpm_table->dpm_levels[dpm_table->count].enabled = i == 0;
(i == 0) ? true : false;
dpm_table->count++; dpm_table->count++;
} }
} }
......
...@@ -1888,7 +1888,7 @@ static int polaris10_populate_avfs_parameters(struct pp_hwmgr *hwmgr) ...@@ -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_VDROOP_TABLE_CKSOFF << BTCGB1_Vdroop_Enable_SHIFT) |
(avfs_params.ucEnableGB_FUSE_TABLE_CKSON << AVFSGB0_Vdroop_Enable_SHIFT) | (avfs_params.ucEnableGB_FUSE_TABLE_CKSON << AVFSGB0_Vdroop_Enable_SHIFT) |
(avfs_params.ucEnableGB_FUSE_TABLE_CKSOFF << AVFSGB1_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; return result;
} }
......
...@@ -295,9 +295,8 @@ static int vegam_process_firmware_header(struct pp_hwmgr *hwmgr) ...@@ -295,9 +295,8 @@ static int vegam_process_firmware_header(struct pp_hwmgr *hwmgr)
static bool vegam_is_dpm_running(struct pp_hwmgr *hwmgr) static bool vegam_is_dpm_running(struct pp_hwmgr *hwmgr)
{ {
return (1 == PHM_READ_INDIRECT_FIELD(hwmgr->device, return 1 == PHM_READ_INDIRECT_FIELD(hwmgr->device,
CGS_IND_REG__SMC, FEATURE_STATUS, VOLTAGE_CONTROLLER_ON)) CGS_IND_REG__SMC, FEATURE_STATUS, VOLTAGE_CONTROLLER_ON);
? true : false;
} }
static uint32_t vegam_get_mac_definition(uint32_t value) static uint32_t vegam_get_mac_definition(uint32_t value)
...@@ -1660,7 +1659,7 @@ static int vegam_populate_avfs_parameters(struct pp_hwmgr *hwmgr) ...@@ -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_CKSON << AVFSGB0_Vdroop_Enable_SHIFT) |
(avfs_params.ucEnableGB_FUSE_TABLE_CKSOFF << AVFSGB1_Vdroop_Enable_SHIFT); (avfs_params.ucEnableGB_FUSE_TABLE_CKSOFF << AVFSGB1_Vdroop_Enable_SHIFT);
data->apply_avfs_cks_off_voltage = data->apply_avfs_cks_off_voltage =
(avfs_params.ucEnableApplyAVFS_CKS_OFF_Voltage == 1) ? true : false; avfs_params.ucEnableApplyAVFS_CKS_OFF_Voltage == 1;
} }
return result; return result;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment