From nobody Sun Feb 8 13:17:22 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95470C77B7F for ; Tue, 16 May 2023 17:30:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231394AbjEPRal (ORCPT ); Tue, 16 May 2023 13:30:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229883AbjEPRaj (ORCPT ); Tue, 16 May 2023 13:30:39 -0400 Received: from 189.cn (ptr.189.cn [183.61.185.103]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 88453F7 for ; Tue, 16 May 2023 10:30:34 -0700 (PDT) HMM_SOURCE_IP: 10.64.8.31:34798.1811634643 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-114.242.206.180 (unknown [10.64.8.31]) by 189.cn (HERMES) with SMTP id 565D31001F4; Wed, 17 May 2023 01:30:31 +0800 (CST) Received: from ([114.242.206.180]) by gateway-151646-dep-75648544bd-pgxlx with ESMTP id a26d85785d524ee0bd802022817a2a6a for suijingfeng@loongson.cn; Wed, 17 May 2023 01:30:32 CST X-Transaction-ID: a26d85785d524ee0bd802022817a2a6a X-Real-From: 15330273260@189.cn X-Receive-IP: 114.242.206.180 X-MEDUSA-Status: 0 Sender: 15330273260@189.cn From: Sui Jingfeng <15330273260@189.cn> To: Sui Jingfeng , Li Yi Cc: Thomas Zimmermann , Maarten Lankhorst , Maxime Ripard , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn Subject: [PATCH] drm/drm_vblank.c: avoid unsigned int to signed int cast Date: Wed, 17 May 2023 01:30:26 +0800 Message-Id: <20230516173026.2990705-1-15330273260@189.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: 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 Reviewed-by: Thomas Zimmermann Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Thomas Zimmermann Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org Cc: loongson-kernel@lists.loongnix.cn --- 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 *c= rtc, =20 /* Valid dotclock? */ if (dotclock > 0) { - int frame_size =3D mode->crtc_htotal * mode->crtc_vtotal; + u64 frame_size =3D mode->crtc_htotal * mode->crtc_vtotal; =20 /* * Convert scanline length in pixels and video @@ -630,7 +630,7 @@ void drm_calc_timestamping_constants(struct drm_crtc *c= rtc, * in nanoseconds: */ linedur_ns =3D div_u64((u64) mode->crtc_htotal * 1000000, dotclock); - framedur_ns =3D div_u64((u64) frame_size * 1000000, dotclock); + framedur_ns =3D div_u64(frame_size * 1000000, dotclock); =20 /* * Fields of interlaced scanout modes are only half a frame duration. --=20 2.25.1