From: Thomas Zimmermann <tzimmermann@suse.de>
To: Sui Jingfeng <suijingfeng@loongson.cn>, suijingfeng <15330273260@189.cn>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/drm_vblank.c: avoid unsigned int to signed int cast
Date: Tue, 16 May 2023 19:06:58 +0200 [thread overview]
Message-ID: <c4a08b01-6d81-a21f-ba9f-ade2b447ff6d@suse.de> (raw)
In-Reply-To: <20230516165931.2989639-1-suijingfeng@loongson.cn>
[-- Attachment #1.1: Type: text/plain, Size: 2098 bytes --]
Am 16.05.23 um 18:59 schrieb Sui Jingfeng:
> Both mode->crtc_htotal and mode->crtc_vtotal are u16 type,
> mode->crtc_htotal * mode->crtc_vtotal will results a unsigned type.
> Using a u32 is enough to store the result, but considering that the
> result will be casted to u64 soon after. We use a u64 type directly.
>
> So there no need to cast it to signed type and cast back then.
>
> Signed-off-by: Sui Jingfeng <suijingfeng@loongson.cn>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Maxime Ripard <mripard@kernel.org>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: David Airlie <airlied@gmail.com>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: dri-devel@lists.freedesktop.org
> Cc: linux-kernel@vger.kernel.org
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
> drivers/gpu/drm/drm_vblank.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c
> index 877e2067534f..d99c404b181b 100644
> --- a/drivers/gpu/drm/drm_vblank.c
> +++ b/drivers/gpu/drm/drm_vblank.c
> @@ -622,7 +622,7 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc,
>
> /* Valid dotclock? */
> if (dotclock > 0) {
> - int frame_size = mode->crtc_htotal * mode->crtc_vtotal;
> + u64 frame_size = mode->crtc_htotal * mode->crtc_vtotal;
>
> /*
> * Convert scanline length in pixels and video
> @@ -630,7 +630,7 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc,
> * in nanoseconds:
> */
> linedur_ns = div_u64((u64) mode->crtc_htotal * 1000000, dotclock);
> - framedur_ns = div_u64((u64) frame_size * 1000000, dotclock);
> + framedur_ns = div_u64(frame_size * 1000000, dotclock);
>
> /*
> * Fields of interlaced scanout modes are only half a frame duration.
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]
next prev parent reply other threads:[~2023-05-16 17:07 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-16 16:59 Sui Jingfeng
2023-05-16 17:06 ` Thomas Zimmermann [this message]
2023-05-16 17:13 ` Sui Jingfeng
2023-05-16 17:30 Sui Jingfeng
2023-05-17 10:59 ` David Laight
2023-05-17 18:08 ` Sui Jingfeng
2023-05-22 11:29 ` Jani Nikula
2023-05-22 11:55 ` Sui Jingfeng
2023-05-22 12:07 ` David Laight
2023-05-22 12:13 ` Jani Nikula
2023-05-22 12:53 ` Sui Jingfeng
2023-05-22 15:01 ` Jani Nikula
2023-05-23 3:55 ` Sui Jingfeng
2023-05-23 4:26 ` Sui Jingfeng
2023-05-23 8:12 ` Sui Jingfeng
2023-05-23 8:50 ` David Laight
2023-05-23 9:55 ` Sui Jingfeng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c4a08b01-6d81-a21f-ba9f-ade2b447ff6d@suse.de \
--to=tzimmermann@suse.de \
--cc=15330273260@189.cn \
--cc=airlied@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=suijingfeng@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®