Skip to contentSkip to conversation

drm/amd/display: Simplify condition in try_disable_dsc

PATCH In review Nathan Chancellor 2 participants 2 messages Sep 22, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/display: Simplify condition in try_disable_dsc

Clang warns:

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_mst_types.c:637:8:
warning: logical not is only applied to the left hand side of this comparison [-Wlogical-not-parentheses]

                                && !params[i].clock_force_enable == DSC_CLK_FORCE_DEFAULT) {
                                   ^                             ~~
drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_mst_types.c:637:8:
note: add parentheses after the '!' to evaluate the comparison first
                                && !params[i].clock_force_enable == DSC_CLK_FORCE_DEFAULT) {
                                   ^
                                    (

) drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_mst_types.c:637:8:
note: add parentheses around left hand side expression to silence this warning

                                && !params[i].clock_force_enable == DSC_CLK_FORCE_DEFAULT) {
                                   ^
                                   (                            )

1 warning generated.

The expression "!a == 0" can be more simply written as "a", which makes it easier to reason about the logic and prevents the warning.

Fixes 0749ddeb7d6c ("drm/amd/display: Add DSC force disable to dsc_clock_en debugfs entry")
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +1 -1
index 9d7333a36fac..0852a24ee392 100644
@@ -634,7 +634,7 @@ static void try_disable_dsc(struct drm_atomic_state *state,
 	for (i = 0; i < count; i++) {
 		if (vars[i].dsc_enabled
 				&& vars[i].bpp_x16 == params[i].bw_range.max_target_bpp_x16
-				&& !params[i].clock_force_enable == DSC_CLK_FORCE_DEFAULT) {
+				&& params[i].clock_force_enable) {
 			kbps_increase[i] = params[i].bw_range.stream_kbps - params[i].bw_range.max_kbps;
 			tried[i] = false;
 			remaining_to_try += 1;

base-commit: 6651cdf3bfeeaeb499db11668313666bf756579a

Signature · 1 line
2.28.0
#1 lore raw
Quoted 20 lines · Nathan Chancellor

Clang warns:

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_mst_types.c:637:8:
warning: logical not is only applied to the left hand side of this comparison [-Wlogical-not-parentheses]

                                && !params[i].clock_force_enable == DSC_CLK_FORCE_DEFAULT) {
                                   ^                             ~~
drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_mst_types.c:637:8:
note: add parentheses after the '!' to evaluate the comparison first
                                && !params[i].clock_force_enable == DSC_CLK_FORCE_DEFAULT) {
                                   ^
                                    (

) drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_mst_types.c:637:8:
note: add parentheses around left hand side expression to silence this warning

                                && !params[i].clock_force_enable == DSC_CLK_FORCE_DEFAULT) {
                                   ^
                                   (                            )
Quoted 8 lines

1 warning generated.

The expression "!a == 0" can be more simply written as "a", which makes it easier to reason about the logic and prevents the warning.

Fixes 0749ddeb7d6c ("drm/amd/display: Add DSC force disable to dsc_clock_en debugfs entry")

@Wentland, Harry or @Leo (Sunpeng) Li can you provide some guidance on what the logic is supposed to be here?

Thanks,

Alex

Quoted 18 lines
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +1 -1
index 9d7333a36fac..0852a24ee392 100644
@@ -634,7 +634,7 @@ static void try_disable_dsc(struct drm_atomic_state *state,
        for (i = 0; i < count; i++) {
                if (vars[i].dsc_enabled
                                && vars[i].bpp_x16 == params[i].bw_range.max_target_bpp_x16
-                               && !params[i].clock_force_enable == DSC_CLK_FORCE_DEFAULT) {
+                               && params[i].clock_force_enable) {
                        kbps_increase[i] = params[i].bw_range.stream_kbps - params[i].bw_range.max_kbps;
                        tried[i] = false;
                        remaining_to_try += 1;
Quoted 8 lines

base-commit: 6651cdf3bfeeaeb499db11668313666bf756579a --
2.28.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel