Skip to content

Commit 9ab06ab

Browse files
LiaoYuanhong-vivoalexdeucher
authored andcommitted
drm/amd/pm/powerplay/smumgr: remove redundant ternary operators
For ternary operators in the form of "a ? true : false", if 'a' itself returns a boolean result, the ternary operator can be omitted. Remove redundant ternary operators to clean up the code. Swap variable positions on either side of '==' to enhance readability. Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent fa740b1 commit 9ab06ab

4 files changed

Lines changed: 8 additions & 12 deletions

File tree

drivers/gpu/drm/amd/pm/powerplay/smumgr/fiji_smumgr.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2540,9 +2540,8 @@ static int fiji_initialize_mc_reg_table(struct pp_hwmgr *hwmgr)
25402540

25412541
static bool fiji_is_dpm_running(struct pp_hwmgr *hwmgr)
25422542
{
2543-
return (1 == PHM_READ_INDIRECT_FIELD(hwmgr->device,
2544-
CGS_IND_REG__SMC, FEATURE_STATUS, VOLTAGE_CONTROLLER_ON))
2545-
? true : false;
2543+
return PHM_READ_INDIRECT_FIELD(hwmgr->device,
2544+
CGS_IND_REG__SMC, FEATURE_STATUS, VOLTAGE_CONTROLLER_ON) == 1;
25462545
}
25472546

25482547
static int fiji_update_dpm_settings(struct pp_hwmgr *hwmgr,

drivers/gpu/drm/amd/pm/powerplay/smumgr/iceland_smumgr.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2655,9 +2655,8 @@ static int iceland_initialize_mc_reg_table(struct pp_hwmgr *hwmgr)
26552655

26562656
static bool iceland_is_dpm_running(struct pp_hwmgr *hwmgr)
26572657
{
2658-
return (1 == PHM_READ_INDIRECT_FIELD(hwmgr->device,
2659-
CGS_IND_REG__SMC, FEATURE_STATUS, VOLTAGE_CONTROLLER_ON))
2660-
? true : false;
2658+
return PHM_READ_INDIRECT_FIELD(hwmgr->device,
2659+
CGS_IND_REG__SMC, FEATURE_STATUS, VOLTAGE_CONTROLLER_ON) == 1;
26612660
}
26622661

26632662
const struct pp_smumgr_func iceland_smu_funcs = {

drivers/gpu/drm/amd/pm/powerplay/smumgr/polaris10_smumgr.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2578,9 +2578,8 @@ static int polaris10_initialize_mc_reg_table(struct pp_hwmgr *hwmgr)
25782578

25792579
static bool polaris10_is_dpm_running(struct pp_hwmgr *hwmgr)
25802580
{
2581-
return (1 == PHM_READ_INDIRECT_FIELD(hwmgr->device,
2582-
CGS_IND_REG__SMC, FEATURE_STATUS, VOLTAGE_CONTROLLER_ON))
2583-
? true : false;
2581+
return PHM_READ_INDIRECT_FIELD(hwmgr->device,
2582+
CGS_IND_REG__SMC, FEATURE_STATUS, VOLTAGE_CONTROLLER_ON) == 1;
25842583
}
25852584

25862585
static int polaris10_update_dpm_settings(struct pp_hwmgr *hwmgr,

drivers/gpu/drm/amd/pm/powerplay/smumgr/tonga_smumgr.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3139,9 +3139,8 @@ static int tonga_initialize_mc_reg_table(struct pp_hwmgr *hwmgr)
31393139

31403140
static bool tonga_is_dpm_running(struct pp_hwmgr *hwmgr)
31413141
{
3142-
return (1 == PHM_READ_INDIRECT_FIELD(hwmgr->device,
3143-
CGS_IND_REG__SMC, FEATURE_STATUS, VOLTAGE_CONTROLLER_ON))
3144-
? true : false;
3142+
return PHM_READ_INDIRECT_FIELD(hwmgr->device,
3143+
CGS_IND_REG__SMC, FEATURE_STATUS, VOLTAGE_CONTROLLER_ON) == 1;
31453144
}
31463145

31473146
static int tonga_update_dpm_settings(struct pp_hwmgr *hwmgr,

0 commit comments

Comments
 (0)