[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CADnq5_Ppuwsz3RU0nK3nqUapfuSrS3QDQNZXiKxYUgBvLObWag@mail.gmail.com>
Date: Thu, 4 Sep 2025 10:11:59 -0400
From: Alex Deucher <alexdeucher@...il.com>
To: Liao Yuanhong <liaoyuanhong@...o.com>
Cc: Kenneth Feng <kenneth.feng@....com>, Alex Deucher <alexander.deucher@....com>,
Christian König <christian.koenig@....com>,
David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>,
"open list:AMD POWERPLAY AND SWSMU" <amd-gfx@...ts.freedesktop.org>,
"open list:DRM DRIVERS" <dri-devel@...ts.freedesktop.org>, open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 3/3] drm/amd/pm/powerplay/smumgr: remove redundant ternary operators
Applied the series. Thanks!
Alex
On Thu, Sep 4, 2025 at 4:29 AM Liao Yuanhong <liaoyuanhong@...o.com> wrote:
>
> 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@...o.com>
> ---
> drivers/gpu/drm/amd/pm/powerplay/smumgr/fiji_smumgr.c | 5 ++---
> drivers/gpu/drm/amd/pm/powerplay/smumgr/iceland_smumgr.c | 5 ++---
> drivers/gpu/drm/amd/pm/powerplay/smumgr/polaris10_smumgr.c | 5 ++---
> drivers/gpu/drm/amd/pm/powerplay/smumgr/tonga_smumgr.c | 5 ++---
> 4 files changed, 8 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/pm/powerplay/smumgr/fiji_smumgr.c b/drivers/gpu/drm/amd/pm/powerplay/smumgr/fiji_smumgr.c
> index 5e43ad2b2956..d2dbd90bb427 100644
> --- a/drivers/gpu/drm/amd/pm/powerplay/smumgr/fiji_smumgr.c
> +++ b/drivers/gpu/drm/amd/pm/powerplay/smumgr/fiji_smumgr.c
> @@ -2540,9 +2540,8 @@ static int fiji_initialize_mc_reg_table(struct pp_hwmgr *hwmgr)
>
> static bool fiji_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 PHM_READ_INDIRECT_FIELD(hwmgr->device,
> + CGS_IND_REG__SMC, FEATURE_STATUS, VOLTAGE_CONTROLLER_ON) == 1;
> }
>
> static int fiji_update_dpm_settings(struct pp_hwmgr *hwmgr,
> diff --git a/drivers/gpu/drm/amd/pm/powerplay/smumgr/iceland_smumgr.c b/drivers/gpu/drm/amd/pm/powerplay/smumgr/iceland_smumgr.c
> index 17d2f5bff4a7..1f50f1e74c48 100644
> --- a/drivers/gpu/drm/amd/pm/powerplay/smumgr/iceland_smumgr.c
> +++ b/drivers/gpu/drm/amd/pm/powerplay/smumgr/iceland_smumgr.c
> @@ -2655,9 +2655,8 @@ static int iceland_initialize_mc_reg_table(struct pp_hwmgr *hwmgr)
>
> static bool iceland_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 PHM_READ_INDIRECT_FIELD(hwmgr->device,
> + CGS_IND_REG__SMC, FEATURE_STATUS, VOLTAGE_CONTROLLER_ON) == 1;
> }
>
> const struct pp_smumgr_func iceland_smu_funcs = {
> diff --git a/drivers/gpu/drm/amd/pm/powerplay/smumgr/polaris10_smumgr.c b/drivers/gpu/drm/amd/pm/powerplay/smumgr/polaris10_smumgr.c
> index ff6b563ecbf5..bf6d09572cfc 100644
> --- a/drivers/gpu/drm/amd/pm/powerplay/smumgr/polaris10_smumgr.c
> +++ b/drivers/gpu/drm/amd/pm/powerplay/smumgr/polaris10_smumgr.c
> @@ -2578,9 +2578,8 @@ static int polaris10_initialize_mc_reg_table(struct pp_hwmgr *hwmgr)
>
> static bool polaris10_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 PHM_READ_INDIRECT_FIELD(hwmgr->device,
> + CGS_IND_REG__SMC, FEATURE_STATUS, VOLTAGE_CONTROLLER_ON) == 1;
> }
>
> static int polaris10_update_dpm_settings(struct pp_hwmgr *hwmgr,
> diff --git a/drivers/gpu/drm/amd/pm/powerplay/smumgr/tonga_smumgr.c b/drivers/gpu/drm/amd/pm/powerplay/smumgr/tonga_smumgr.c
> index 6fe6e6abb5d8..2e21f9d066cb 100644
> --- a/drivers/gpu/drm/amd/pm/powerplay/smumgr/tonga_smumgr.c
> +++ b/drivers/gpu/drm/amd/pm/powerplay/smumgr/tonga_smumgr.c
> @@ -3139,9 +3139,8 @@ static int tonga_initialize_mc_reg_table(struct pp_hwmgr *hwmgr)
>
> static bool tonga_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 PHM_READ_INDIRECT_FIELD(hwmgr->device,
> + CGS_IND_REG__SMC, FEATURE_STATUS, VOLTAGE_CONTROLLER_ON) == 1;
> }
>
> static int tonga_update_dpm_settings(struct pp_hwmgr *hwmgr,
> --
> 2.34.1
>
Powered by blists - more mailing lists