From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965316AbeBMRsC (ORCPT ); Tue, 13 Feb 2018 12:48:02 -0500 Received: from gateway30.websitewelcome.com ([192.185.192.34]:47496 "EHLO gateway30.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965057AbeBMRsB (ORCPT ); Tue, 13 Feb 2018 12:48:01 -0500 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-Type: text/plain; charset=us-ascii 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: 12 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.7.4