[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <630b9f2e-00e8-5b54-ad1c-3e4d404454a1@nfschina.com>
Date: Wed, 26 Jul 2023 09:21:50 +0800
From: Su Hui <suhui@...china.com>
To: Dan Carpenter <dan.carpenter@...aro.org>
Cc: Andi Shyti <andi.shyti@...ux.intel.com>,
jani.nikula@...ux.intel.com, joonas.lahtinen@...ux.intel.com,
rodrigo.vivi@...el.com, tvrtko.ursulin@...ux.intel.com,
airlied@...il.com, daniel@...ll.ch, nathan@...nel.org,
ndesaulniers@...gle.com, trix@...hat.com, andrzej.hajda@...el.com,
intel-gfx@...ts.freedesktop.org, llvm@...ts.linux.dev,
kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org,
dri-devel@...ts.freedesktop.org, mripard@...nel.org
Subject: Re: [Intel-gfx] [PATCH v2] drm/i915/tv: avoid possible division by
zero
On 2023/7/25 13:51, Dan Carpenter wrote:
> The reason why the first five attempts had bugs is because we are
> trying to write it in the most complicated way possible, shifting by
> logical not what?
Wonderful! Should I add your name as signed-of-by?
I will send a v3 patch later.
Really thanks for your help!
Su Hui
> regards,
> dan carpenter
>
> diff --git a/drivers/gpu/drm/i915/display/intel_tv.c b/drivers/gpu/drm/i915/display/intel_tv.c
> index 36b479b46b60..6997b6cb1df2 100644
> --- a/drivers/gpu/drm/i915/display/intel_tv.c
> +++ b/drivers/gpu/drm/i915/display/intel_tv.c
> @@ -988,7 +988,13 @@ intel_tv_mode_to_mode(struct drm_display_mode *mode,
> const struct tv_mode *tv_mode,
> int clock)
> {
> - mode->clock = clock / (tv_mode->oversample >> !tv_mode->progressive);
> + int div = tv_mode->oversample;
> +
> + if (!tv_mode->progressive)
> + div >>= 1;
> + if (div == 0)
> + div = 1;
> + mode->clock = clock / div;
>
> /*
> * tv_mode horizontal timings:
> @@ -1135,6 +1141,8 @@ intel_tv_get_config(struct intel_encoder *encoder,
> break;
> default:
> tv_mode.oversample = 1;
> + WARN_ON_ONCE(!tv_mode.progressive);
> + tv_mode.progressive = true;
> break;
> }
>
>
Powered by blists - more mailing lists