Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1031144rwd; Tue, 16 May 2023 10:45:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5oE6Msct9pts48c0YmGHSpIfBV2mKjWUUQ/ejz5SHvmeAJrDslMLkRHU2HKRTVJhJ5ELRn X-Received: by 2002:a05:6a21:9981:b0:101:8b:43a5 with SMTP id ve1-20020a056a21998100b00101008b43a5mr36784985pzb.8.1684259151583; Tue, 16 May 2023 10:45:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684259151; cv=none; d=google.com; s=arc-20160816; b=RIpQ6q3Xm6kVJGqSGs0pAIRypdFmnPKZ5zZL92B/67pd3lhXQIHf9r33dDZl5J12GP dC2n0VJ+p4UUJ+N40//BQ2h7KOV+Rvj0f3fk9W8tCkOoyvFO6+o17WtnLrnuwuvQckTE wtKm/sfV69NYd7WCbJElPA6dlXWOUK0vdNJBou2UgnYQ13vcbjZwjVclBDTtIgvQYTQm aK+cUSRU1N+fePjQOjJjhtIGOrLZ+xDMKllS7VHMNXH/xBd3fVJEkkEEHISeqUGW+fZg ERfao0ROZRSVhz3iIHiYyjMBggzjVYBepPKgRZD87u0AGDc0eYpgasPjPo1u44smDQ1m oF/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:sender:hmm_source_type :hmm_attache_num:hmm_source_ip; bh=B6ujw0eTbLWLqOP+DgO2Crq/hY6aLwq5eJsF78WAcLQ=; b=qV8Iph9xc37IPaoPVHL51QF4f6qdjorAV27nGLIfgAZI8SuMwVMQI9eBATLEvZdVcy mO9GrxVMRKt+ZQnahckyab9ExD27yqfAzdvahZGtsxtxoAa4pe4E6TCJI8k5NNyYtoQQ 96ayvspfPywuXpW+kp7jNdif9UnIReUpqJCCFQ4SE2pdIusehdjuD7K+rRLtTMtQM7qq AVpI/I3/yAgXYtkcTV//ln0h97AlOLnzaWazvTa/yJ0cyDd+Nlk40xVrQyJDJct8//y3 hycroTkYLRBxCD8aWFSzJ8+g59yIZihsGzMprPRbGtT//qIDL/rT/CWQH/0QgNiIfmJQ ZnKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h186-20020a636cc3000000b0050c0305bcc3si18824474pgc.872.2023.05.16.10.45.37; Tue, 16 May 2023 10:45:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229968AbjEPRak (ORCPT + 99 others); Tue, 16 May 2023 13:30:40 -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: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,FROM_LOCAL_DIGITS, FROM_LOCAL_HEX,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 *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. -- 2.25.1