From patchwork Tue Feb 13 16:52:58 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: 10217039 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 AA6D560329 for ; Tue, 13 Feb 2018 17:15:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99AB1286EC for ; Tue, 13 Feb 2018 17:15:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8CFF828EA0; Tue, 13 Feb 2018 17:15:07 +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=ham 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 F38E4286EC for ; Tue, 13 Feb 2018 17:15:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965064AbeBMRPF (ORCPT ); Tue, 13 Feb 2018 12:15:05 -0500 Received: from gateway20.websitewelcome.com ([192.185.60.19]:30091 "EHLO gateway20.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964987AbeBMRPD (ORCPT ); Tue, 13 Feb 2018 12:15:03 -0500 X-Greylist: delayed 1319 seconds by postgrey-1.27 at vger.kernel.org; Tue, 13 Feb 2018 12:15:03 EST Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway20.websitewelcome.com (Postfix) with ESMTP id 7524140102344 for ; Tue, 13 Feb 2018 10:53:03 -0600 (CST) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id ldpHeejlJODN4ldpHeXnHj; Tue, 13 Feb 2018 10:53:03 -0600 Received: from [189.175.4.238] (port=35058 helo=embeddedor) by gator4166.hostgator.com with esmtpa (Exim 4.89_1) (envelope-from ) id 1eldpG-001CH2-So; Tue, 13 Feb 2018 10:53:02 -0600 Date: Tue, 13 Feb 2018 10:52:58 -0600 From: "Gustavo A. R. Silva" To: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] iio: adc: ina2xx: Use 64-bit arithmetic instead of 32-bit Message-ID: <20180213165258.GA12967@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.175.4.238 X-Source-L: No X-Exim-ID: 1eldpG-001CH2-So X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedor) [189.175.4.238]:35058 X-Source-Auth: garsilva@embeddedor.com X-Email-Count: 11 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add suffix ULL to constant 1000 in order to give the compiler complete information about the proper arithmetic to use. Notice that this constant is used in a context that expects an expression of type u64 (64 bits, unsigned). The expression 1000 * sampling_us is currently being evaluated using 32-bit arithmetic. Addresses-Coverity-ID: 1463793 Signed-off-by: Gustavo A. R. Silva --- drivers/iio/adc/ina2xx-adc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c index 0635a79..8649700 100644 --- a/drivers/iio/adc/ina2xx-adc.c +++ b/drivers/iio/adc/ina2xx-adc.c @@ -810,7 +810,7 @@ static int ina2xx_capture_thread(void *data) * multiple times, i.e. samples are dropped. */ do { - timespec64_add_ns(&next, 1000 * sampling_us); + timespec64_add_ns(&next, 1000ULL * sampling_us); delta = timespec64_sub(next, now); delay_us = div_s64(timespec64_to_ns(&delta), 1000); } while (delay_us <= 0);