[PATCH] drm/amd/display: Simplify if conditions

Alex Deucher alexdeucher at gmail.com
Wed Jun 5 14:35:51 UTC 2024


Applied.  Thanks!

Alex

On Tue, Jun 4, 2024 at 9:07 AM Thorsten Blum <thorsten.blum at toblux.com> wrote:
>
> The if conditions !A || A && B can be simplified to !A || B.
>
> Fixes the following Coccinelle/coccicheck warnings reported by
> excluded_middle.cocci:
>
>         WARNING !A || A && B is equivalent to !A || B
>         WARNING !A || A && B is equivalent to !A || B
>         WARNING !A || A && B is equivalent to !A || B
>
> Compile-tested only.
>
> Signed-off-by: Thorsten Blum <thorsten.blum at toblux.com>
> ---
>  drivers/gpu/drm/amd/display/dc/dml2/dml2_dc_resource_mgmt.c | 6 +++---
>  .../gpu/drm/amd/display/dc/dml2/dml2_translation_helper.c   | 2 +-
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/dml2/dml2_dc_resource_mgmt.c b/drivers/gpu/drm/amd/display/dc/dml2/dml2_dc_resource_mgmt.c
> index ad2a6b4769fe..940081df6dc0 100644
> --- a/drivers/gpu/drm/amd/display/dc/dml2/dml2_dc_resource_mgmt.c
> +++ b/drivers/gpu/drm/amd/display/dc/dml2/dml2_dc_resource_mgmt.c
> @@ -68,7 +68,7 @@ static bool get_plane_id(struct dml2_context *dml2, const struct dc_state *state
>                 if (state->streams[i]->stream_id == stream_id) {
>                         for (j = 0; j < state->stream_status[i].plane_count; j++) {
>                                 if (state->stream_status[i].plane_states[j] == plane &&
> -                                       (!is_plane_duplicate || (is_plane_duplicate && (j == plane_index)))) {
> +                                       (!is_plane_duplicate || (j == plane_index))) {
>                                         *plane_id = (i << 16) | j;
>                                         return true;
>                                 }
> @@ -707,8 +707,8 @@ static void free_unused_pipes_for_plane(struct dml2_context *ctx, struct dc_stat
>         for (i = 0; i < ctx->config.dcn_pipe_count; i++) {
>                 if (state->res_ctx.pipe_ctx[i].plane_state == plane &&
>                         state->res_ctx.pipe_ctx[i].stream->stream_id == stream_id &&
> -                       (!is_plane_duplicate || (is_plane_duplicate &&
> -                       ctx->v20.scratch.dml_to_dc_pipe_mapping.dml_pipe_idx_to_plane_index[state->res_ctx.pipe_ctx[i].pipe_idx] == plane_index)) &&
> +                       (!is_plane_duplicate ||
> +                       ctx->v20.scratch.dml_to_dc_pipe_mapping.dml_pipe_idx_to_plane_index[state->res_ctx.pipe_ctx[i].pipe_idx] == plane_index) &&
>                         !is_pipe_used(pool, state->res_ctx.pipe_ctx[i].pipe_idx)) {
>                         free_pipe(&state->res_ctx.pipe_ctx[i]);
>                 }
> diff --git a/drivers/gpu/drm/amd/display/dc/dml2/dml2_translation_helper.c b/drivers/gpu/drm/amd/display/dc/dml2/dml2_translation_helper.c
> index a41812598ce8..b2bbf7988f92 100644
> --- a/drivers/gpu/drm/amd/display/dc/dml2/dml2_translation_helper.c
> +++ b/drivers/gpu/drm/amd/display/dc/dml2/dml2_translation_helper.c
> @@ -979,7 +979,7 @@ static bool get_plane_id(struct dml2_context *dml2, const struct dc_state *conte
>                 if (context->streams[i]->stream_id == stream_id) {
>                         for (j = 0; j < context->stream_status[i].plane_count; j++) {
>                                 if (context->stream_status[i].plane_states[j] == plane &&
> -                                       (!is_plane_duplicate || (is_plane_duplicate && (j == plane_index)))) {
> +                                       (!is_plane_duplicate || (j == plane_index))) {
>                                         *plane_id = (i << 16) | j;
>                                         return true;
>                                 }
> --
> 2.39.2
>


More information about the dri-devel mailing list