From: Sui Jingfeng <15330273260@189.cn>
To: Thomas Zimmermann <tzimmermann@suse.de>,
Sui Jingfeng <suijingfeng@loongson.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: Wed, 17 May 2023 01:13:30 +0800 [thread overview]
Message-ID: <530369f4-1edd-d8cf-031e-a8effdf15510@189.cn> (raw)
In-Reply-To: <c4a08b01-6d81-a21f-ba9f-ade2b447ff6d@suse.de>
Hi,
On 2023/5/17 01:06, Thomas Zimmermann wrote:
>
>
> 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>
>
Thanks a lot, thanks for the response time also.
>> ---
>> 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.
>
next prev parent reply other threads:[~2023-05-16 17:13 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
2023-05-16 17:13 ` Sui Jingfeng [this message]
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=530369f4-1edd-d8cf-031e-a8effdf15510@189.cn \
--to=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 \
--cc=tzimmermann@suse.de \
/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®