From: "Gustavo A. R. Silva" <garsilva@embeddedor.com>
To: Jonathan Cameron <jic23@kernel.org>,
Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
"Gustavo A. R. Silva" <garsilva@embeddedor.com>
Subject: [PATCH] iio: adc: ina2xx: Use 64-bit arithmetic instead of 32-bit
Date: Tue, 13 Feb 2018 10:52:58 -0600 [thread overview]
Message-ID: <20180213165258.GA12967@embeddedor.com> (raw)
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 <garsilva@embeddedor.com>
---
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
next reply other threads:[~2018-02-13 17:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-13 16:52 Gustavo A. R. Silva [this message]
2018-02-17 12:38 ` [PATCH] iio: adc: ina2xx: Use 64-bit arithmetic instead of 32-bit Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180213165258.GA12967@embeddedor.com \
--to=garsilva@embeddedor.com \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.