diff mbox series

drm/i915/tc: Use standard ternary operator instead of GCC extension

Message ID 20230608220037.1555814-1-gildekel@chromium.org (mailing list archive)
State New, archived
Headers show
Series drm/i915/tc: Use standard ternary operator instead of GCC extension | expand

Commit Message

Gil Dekel June 8, 2023, 10 p.m. UTC
The ternary expression:

  x ? : y

is a GCC extension and is not a part of C/C++ standard.

Use the canonical form instead to reduce dependency over GCC extension.

Signed-off-by: Gil Dekel <gildekel@chromium.org>
---
 drivers/gpu/drm/i915/display/intel_display_power_well.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--
Gil Dekel, Software Engineer, Google / ChromeOS Display and Graphics

Comments

Jani Nikula June 9, 2023, 9:15 a.m. UTC | #1
On Thu, 08 Jun 2023, Gil Dekel <gildekel@chromium.org> wrote:
> The ternary expression:
>
>   x ? : y
>
> is a GCC extension and is not a part of C/C++ standard.
>
> Use the canonical form instead to reduce dependency over GCC extension.

Thanks for the patch, but no thanks, we'll keep it as it is.

It's acceptable use of GCC extensions in kernel, it's supported by both
GCC and Clang, and there are thousands of uses of uses in kernel, and
dozens in i915 alone. I don't want to open the door for an influx of
patches changing this.

Besides, it's one of the better GCC extensions there is, avoiding the
unnecessary duplication and verbosity.


BR,
Jani.

>
> Signed-off-by: Gil Dekel <gildekel@chromium.org>
> ---
>  drivers/gpu/drm/i915/display/intel_display_power_well.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_display_power_well.c b/drivers/gpu/drm/i915/display/intel_display_power_well.c
> index 916009894d89c..39d0dbad589bf 100644
> --- a/drivers/gpu/drm/i915/display/intel_display_power_well.c
> +++ b/drivers/gpu/drm/i915/display/intel_display_power_well.c
> @@ -255,7 +255,9 @@ static void hsw_wait_for_power_well_enable(struct drm_i915_private *dev_priv,
>  {
>  	const struct i915_power_well_regs *regs = power_well->desc->ops->regs;
>  	int pw_idx = i915_power_well_instance(power_well)->hsw.idx;
> -	int timeout = power_well->desc->enable_timeout ? : 1;
> +	int timeout = power_well->desc->enable_timeout ?
> +			      power_well->desc->enable_timeout :
> +			      1;
>
>  	/*
>  	 * For some power wells we're not supposed to watch the status bit for
> --
> Gil Dekel, Software Engineer, Google / ChromeOS Display and Graphics
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_display_power_well.c b/drivers/gpu/drm/i915/display/intel_display_power_well.c
index 916009894d89c..39d0dbad589bf 100644
--- a/drivers/gpu/drm/i915/display/intel_display_power_well.c
+++ b/drivers/gpu/drm/i915/display/intel_display_power_well.c
@@ -255,7 +255,9 @@  static void hsw_wait_for_power_well_enable(struct drm_i915_private *dev_priv,
 {
 	const struct i915_power_well_regs *regs = power_well->desc->ops->regs;
 	int pw_idx = i915_power_well_instance(power_well)->hsw.idx;
-	int timeout = power_well->desc->enable_timeout ? : 1;
+	int timeout = power_well->desc->enable_timeout ?
+			      power_well->desc->enable_timeout :
+			      1;

 	/*
 	 * For some power wells we're not supposed to watch the status bit for