drivers/gpu/drm/amd/display/dc/dio/dcn10/dcn10_link_encoder.c | 2 +- .../drm/amd/display/dc/dio/dcn35/dcn35_dio_stream_encoder.c | 2 +- drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c | 2 +- drivers/gpu/drm/amd/display/dc/link/hwss/link_hwss_dio.c | 3 +-- drivers/gpu/drm/amd/display/modules/freesync/freesync.c | 4 ++-- 5 files changed, 6 insertions(+), 7 deletions(-)
For ternary operators in the form of "a ? true : false" or
"a ? false : true", if 'a' itself returns a boolean result, the ternary
operator can be omitted. Remove redundant ternary operators to clean up the
code.
Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com>
---
drivers/gpu/drm/amd/display/dc/dio/dcn10/dcn10_link_encoder.c | 2 +-
.../drm/amd/display/dc/dio/dcn35/dcn35_dio_stream_encoder.c | 2 +-
drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c | 2 +-
drivers/gpu/drm/amd/display/dc/link/hwss/link_hwss_dio.c | 3 +--
drivers/gpu/drm/amd/display/modules/freesync/freesync.c | 4 ++--
5 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/dio/dcn10/dcn10_link_encoder.c b/drivers/gpu/drm/amd/display/dc/dio/dcn10/dcn10_link_encoder.c
index e0558a78b11c..1c1228116487 100644
--- a/drivers/gpu/drm/amd/display/dc/dio/dcn10/dcn10_link_encoder.c
+++ b/drivers/gpu/drm/amd/display/dc/dio/dcn10/dcn10_link_encoder.c
@@ -812,7 +812,7 @@ bool dcn10_link_encoder_validate_output_with_stream(
enc10, &stream->timing);
break;
case SIGNAL_TYPE_EDP:
- is_valid = (stream->timing.pixel_encoding == PIXEL_ENCODING_RGB) ? true : false;
+ is_valid = stream->timing.pixel_encoding == PIXEL_ENCODING_RGB;
break;
case SIGNAL_TYPE_VIRTUAL:
is_valid = true;
diff --git a/drivers/gpu/drm/amd/display/dc/dio/dcn35/dcn35_dio_stream_encoder.c b/drivers/gpu/drm/amd/display/dc/dio/dcn35/dcn35_dio_stream_encoder.c
index 6ab2a218b769..6f30b6cc3c76 100644
--- a/drivers/gpu/drm/amd/display/dc/dio/dcn35/dcn35_dio_stream_encoder.c
+++ b/drivers/gpu/drm/amd/display/dc/dio/dcn35/dcn35_dio_stream_encoder.c
@@ -397,7 +397,7 @@ static bool enc35_is_fifo_enabled(struct stream_encoder *enc)
uint32_t reset_val;
REG_GET(DIG_FIFO_CTRL0, DIG_FIFO_ENABLE, &reset_val);
- return (reset_val == 0) ? false : true;
+ return reset_val != 0;
}
void enc35_disable_fifo(struct stream_encoder *enc)
{
diff --git a/drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c b/drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c
index 0318260370ed..9deb03a18ccc 100644
--- a/drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c
+++ b/drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c
@@ -535,7 +535,7 @@ static bool dml2_validate_only(struct dc_state *context, enum dc_validate_mode v
if (result)
result = does_configuration_meet_sw_policies(dml2, &dml2->v20.scratch.cur_display_config, &dml2->v20.scratch.mode_support_info);
- return (result == 1) ? true : false;
+ return result == 1;
}
static void dml2_apply_debug_options(const struct dc *dc, struct dml2_context *dml2)
diff --git a/drivers/gpu/drm/amd/display/dc/link/hwss/link_hwss_dio.c b/drivers/gpu/drm/amd/display/dc/link/hwss/link_hwss_dio.c
index b68bcc9fca0a..892907991f91 100644
--- a/drivers/gpu/drm/amd/display/dc/link/hwss/link_hwss_dio.c
+++ b/drivers/gpu/drm/amd/display/dc/link/hwss/link_hwss_dio.c
@@ -138,8 +138,7 @@ void setup_dio_stream_attribute(struct pipe_ctx *pipe_ctx)
stream_encoder->funcs->dvi_set_stream_attribute(
stream_encoder,
&stream->timing,
- (stream->signal == SIGNAL_TYPE_DVI_DUAL_LINK) ?
- true : false);
+ stream->signal == SIGNAL_TYPE_DVI_DUAL_LINK);
else if (dc_is_lvds_signal(stream->signal))
stream_encoder->funcs->lvds_set_stream_attribute(
stream_encoder,
diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
index 71efd2770c99..ce421bcddcb0 100644
--- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
+++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
@@ -226,8 +226,8 @@ static void update_v_total_for_static_ramp(
unsigned int target_duration_in_us =
calc_duration_in_us_from_refresh_in_uhz(
in_out_vrr->fixed.target_refresh_in_uhz);
- bool ramp_direction_is_up = (current_duration_in_us >
- target_duration_in_us) ? true : false;
+ bool ramp_direction_is_up = current_duration_in_us >
+ target_duration_in_us;
/* Calculate ratio between new and current frame duration with 3 digit */
unsigned int frame_duration_ratio = div64_u64(1000000,
--
2.34.1
Applied. Thanks! On Thu, Sep 4, 2025 at 3:29 AM Liao Yuanhong <liaoyuanhong@vivo.com> wrote: > > For ternary operators in the form of "a ? true : false" or > "a ? false : true", if 'a' itself returns a boolean result, the ternary > operator can be omitted. Remove redundant ternary operators to clean up the > code. > > Signed-off-by: Liao Yuanhong <liaoyuanhong@vivo.com> > --- > drivers/gpu/drm/amd/display/dc/dio/dcn10/dcn10_link_encoder.c | 2 +- > .../drm/amd/display/dc/dio/dcn35/dcn35_dio_stream_encoder.c | 2 +- > drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c | 2 +- > drivers/gpu/drm/amd/display/dc/link/hwss/link_hwss_dio.c | 3 +-- > drivers/gpu/drm/amd/display/modules/freesync/freesync.c | 4 ++-- > 5 files changed, 6 insertions(+), 7 deletions(-) > > diff --git a/drivers/gpu/drm/amd/display/dc/dio/dcn10/dcn10_link_encoder.c b/drivers/gpu/drm/amd/display/dc/dio/dcn10/dcn10_link_encoder.c > index e0558a78b11c..1c1228116487 100644 > --- a/drivers/gpu/drm/amd/display/dc/dio/dcn10/dcn10_link_encoder.c > +++ b/drivers/gpu/drm/amd/display/dc/dio/dcn10/dcn10_link_encoder.c > @@ -812,7 +812,7 @@ bool dcn10_link_encoder_validate_output_with_stream( > enc10, &stream->timing); > break; > case SIGNAL_TYPE_EDP: > - is_valid = (stream->timing.pixel_encoding == PIXEL_ENCODING_RGB) ? true : false; > + is_valid = stream->timing.pixel_encoding == PIXEL_ENCODING_RGB; > break; > case SIGNAL_TYPE_VIRTUAL: > is_valid = true; > diff --git a/drivers/gpu/drm/amd/display/dc/dio/dcn35/dcn35_dio_stream_encoder.c b/drivers/gpu/drm/amd/display/dc/dio/dcn35/dcn35_dio_stream_encoder.c > index 6ab2a218b769..6f30b6cc3c76 100644 > --- a/drivers/gpu/drm/amd/display/dc/dio/dcn35/dcn35_dio_stream_encoder.c > +++ b/drivers/gpu/drm/amd/display/dc/dio/dcn35/dcn35_dio_stream_encoder.c > @@ -397,7 +397,7 @@ static bool enc35_is_fifo_enabled(struct stream_encoder *enc) > uint32_t reset_val; > > REG_GET(DIG_FIFO_CTRL0, DIG_FIFO_ENABLE, &reset_val); > - return (reset_val == 0) ? false : true; > + return reset_val != 0; > } > void enc35_disable_fifo(struct stream_encoder *enc) > { > diff --git a/drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c b/drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c > index 0318260370ed..9deb03a18ccc 100644 > --- a/drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c > +++ b/drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c > @@ -535,7 +535,7 @@ static bool dml2_validate_only(struct dc_state *context, enum dc_validate_mode v > if (result) > result = does_configuration_meet_sw_policies(dml2, &dml2->v20.scratch.cur_display_config, &dml2->v20.scratch.mode_support_info); > > - return (result == 1) ? true : false; > + return result == 1; > } > > static void dml2_apply_debug_options(const struct dc *dc, struct dml2_context *dml2) > diff --git a/drivers/gpu/drm/amd/display/dc/link/hwss/link_hwss_dio.c b/drivers/gpu/drm/amd/display/dc/link/hwss/link_hwss_dio.c > index b68bcc9fca0a..892907991f91 100644 > --- a/drivers/gpu/drm/amd/display/dc/link/hwss/link_hwss_dio.c > +++ b/drivers/gpu/drm/amd/display/dc/link/hwss/link_hwss_dio.c > @@ -138,8 +138,7 @@ void setup_dio_stream_attribute(struct pipe_ctx *pipe_ctx) > stream_encoder->funcs->dvi_set_stream_attribute( > stream_encoder, > &stream->timing, > - (stream->signal == SIGNAL_TYPE_DVI_DUAL_LINK) ? > - true : false); > + stream->signal == SIGNAL_TYPE_DVI_DUAL_LINK); > else if (dc_is_lvds_signal(stream->signal)) > stream_encoder->funcs->lvds_set_stream_attribute( > stream_encoder, > diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c > index 71efd2770c99..ce421bcddcb0 100644 > --- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c > +++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c > @@ -226,8 +226,8 @@ static void update_v_total_for_static_ramp( > unsigned int target_duration_in_us = > calc_duration_in_us_from_refresh_in_uhz( > in_out_vrr->fixed.target_refresh_in_uhz); > - bool ramp_direction_is_up = (current_duration_in_us > > - target_duration_in_us) ? true : false; > + bool ramp_direction_is_up = current_duration_in_us > > + target_duration_in_us; > > /* Calculate ratio between new and current frame duration with 3 digit */ > unsigned int frame_duration_ratio = div64_u64(1000000, > -- > 2.34.1 >
© 2016 - 2025 Red Hat, Inc.