From patchwork Tue May 16 17:30:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng <15330273260@189.cn> X-Patchwork-Id: 94848 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp593551vqo; Tue, 16 May 2023 10:32:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7SXLDqq8ri8s0ERfWrW9dlw0Dn8EsYewU0gbot6O+VH5SBVmMxqA+bNoJcHRIrI+kPODQ2 X-Received: by 2002:a05:6a00:2313:b0:641:3bf8:6514 with SMTP id h19-20020a056a00231300b006413bf86514mr53142670pfh.10.1684258352272; Tue, 16 May 2023 10:32:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684258352; cv=none; d=google.com; s=arc-20160816; b=EIUmnO0gNU2CgE+yNNw9X8zdlk2wwusDQ3tPue0n4tZeEG3z6NlJX8SkJjlICKboQW xWe/HPWBcL+OeTTe+uy5pT8i1DoOM5dp0eKEnhXnZ0gSf6nidTRypom9A+v/EoM3L12I b4JOpsI9OzjF6UT9tMTolTqmp9UrAIiVKxcC5TFojofg1sdyV88m/x9aRPIyt6cDVNxL rWT7yxVV6aa8VkBVGspEathC/WtyRJY8gBmW+V2Y9wuw7T8TxRs9AkpK5BYi093QP5kd OYfX0LiPVpxoPRKyt8H9z1nqjcY1zYnVVzWi8VqPJxQbVfAQqcmt1NeiERNvG0uGDLCu NnMQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g3-20020a636b03000000b0050bcbcaf7edsi18783351pgc.820.2023.05.16.10.32.15; Tue, 16 May 2023 10:32:32 -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 S231192AbjEPRal (ORCPT + 99 others); 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766071134775919004?= X-GMAIL-MSGID: =?utf-8?q?1766072885991874341?= 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.