From patchwork Tue Feb 27 23:19:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 10246361 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 920E460362 for ; Tue, 27 Feb 2018 23:41:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 850D428B0B for ; Tue, 27 Feb 2018 23:41:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7932328B0D; Tue, 27 Feb 2018 23:41:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1032928B0B for ; Tue, 27 Feb 2018 23:41:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751809AbeB0Xlk (ORCPT ); Tue, 27 Feb 2018 18:41:40 -0500 Received: from gateway22.websitewelcome.com ([192.185.47.100]:18955 "EHLO gateway22.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751800AbeB0Xlk (ORCPT ); Tue, 27 Feb 2018 18:41:40 -0500 X-Greylist: delayed 1305 seconds by postgrey-1.27 at vger.kernel.org; Tue, 27 Feb 2018 18:41:40 EST Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway22.websitewelcome.com (Postfix) with ESMTP id 6D072FB7E for ; Tue, 27 Feb 2018 17:19:55 -0600 (CST) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id qoXLehVnPRMsBqoXLeztUa; Tue, 27 Feb 2018 17:19:55 -0600 Received: from [189.152.175.32] (port=55808 helo=embeddedor) by gator4166.hostgator.com with esmtpa (Exim 4.89_1) (envelope-from ) id 1eqoXK-001Bxn-M1; Tue, 27 Feb 2018 17:19:54 -0600 Date: Tue, 27 Feb 2018 17:19:52 -0600 From: "Gustavo A. R. Silva" To: Andy Shevchenko , Bjorn Helgaas Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] PCI/ASPM: Change type of threshold_ns variable to u32 Message-ID: <20180227231952.GA9001@embeddedor.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 189.152.175.32 X-Source-L: No X-Exim-ID: 1eqoXK-001Bxn-M1 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedor) [189.152.175.32]:55808 X-Source-Auth: garsilva@embeddedor.com X-Email-Count: 3 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It seems that the expression threshold_us * 1000 will never exceed the 32-bit limits [1]. So changing the type of threshold_ns from u64 to u32 seems sensible [2]. [1] https://marc.info/?l=linux-kernel&m=151855021100725&w=2 [2] https://marc.info/?l=linux-kernel&m=151976318924615&w=2 Addresses-Coverity-ID: 1462501 Signed-off-by: Gustavo A. R. Silva Reviewed-by: Andy Shevchenko --- drivers/pci/pcie/aspm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 57feef2..8633fc4 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -322,7 +322,7 @@ static u32 calc_l1ss_pwron(struct pci_dev *pdev, u32 scale, u32 val) static void encode_l12_threshold(u32 threshold_us, u32 *scale, u32 *value) { - u64 threshold_ns = threshold_us * 1000; + u32 threshold_ns = threshold_us * 1000; /* See PCIe r3.1, sec 7.33.3 and sec 6.18 */ if (threshold_ns < 32) {