All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] spi: bcm2835aux: use 64-bit arithmetic instead of 32-bit
@ 2018-02-07 16:00 ` Gustavo A. R. Silva
  0 siblings, 0 replies; 32+ messages in thread
From: Gustavo A. R. Silva @ 2018-02-07 16:00 UTC (permalink / raw)
  To: Mark Brown, Eric Anholt, Stefan Wahren, Florian Fainelli,
	Ray Jui, Scott Branden, bcm-kernel-feedback-list
  Cc: linux-spi, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
	Gustavo A. R. Silva

Add suffix ULL to constant 9 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
unsigned long long (64 bits, unsigned).

The expression tfr->len * 9 * 1000000 is currently being evaluated
using 32-bit arithmetic.

Addresses-Coverity-ID: 1339619
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 drivers/spi/spi-bcm2835aux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-bcm2835aux.c b/drivers/spi/spi-bcm2835aux.c
index 7428091..a768c23 100644
--- a/drivers/spi/spi-bcm2835aux.c
+++ b/drivers/spi/spi-bcm2835aux.c
@@ -363,7 +363,7 @@ static int bcm2835aux_spi_transfer_one(struct spi_master *master,
 	 * chunk getting transferred - in our case the chunk size
 	 * is 3 bytes, so we approximate this by 9 bits/byte
 	 */
-	xfer_time_us = tfr->len * 9 * 1000000;
+	xfer_time_us = tfr->len * 9ULL * 1000000;
 	do_div(xfer_time_us, spi_used_hz);
 
 	/* run in polling mode for short transfers */
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2018-02-14 16:29 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-07 16:00 [PATCH] spi: bcm2835aux: use 64-bit arithmetic instead of 32-bit Gustavo A. R. Silva
2018-02-07 16:00 ` Gustavo A. R. Silva
2018-02-08  8:22 ` Eric Anholt
2018-02-08  8:22   ` Eric Anholt
2018-02-12 17:57   ` Gustavo A. R. Silva
2018-02-12 17:57     ` Gustavo A. R. Silva
2018-02-08  9:54 ` Ard Biesheuvel
2018-02-08  9:54   ` Ard Biesheuvel
2018-02-08  9:54   ` Ard Biesheuvel
2018-02-12 18:04   ` Gustavo A. R. Silva
2018-02-12 18:04     ` Gustavo A. R. Silva
2018-02-12 18:45     ` Ard Biesheuvel
2018-02-12 18:45       ` Ard Biesheuvel
2018-02-12 19:10       ` Florian Fainelli
2018-02-12 19:10         ` Florian Fainelli
2018-02-12 19:10         ` Florian Fainelli
2018-02-12 19:11         ` Ard Biesheuvel
2018-02-12 19:11           ` Ard Biesheuvel
2018-02-12 19:11           ` Ard Biesheuvel
2018-02-12 19:14           ` Florian Fainelli
2018-02-12 19:14             ` Florian Fainelli
2018-02-12 19:14             ` Florian Fainelli
2018-02-12 19:31 ` Trent Piepho
2018-02-12 19:31   ` Trent Piepho
2018-02-12 19:31   ` Trent Piepho
2018-02-12 19:38   ` [PATCH] spi: bcm2835aux: Avoid 64-bit arithmetic in xfer len calc Trent Piepho
2018-02-12 19:38     ` Trent Piepho
2018-02-14 16:04     ` Mark Brown
2018-02-14 16:04       ` Mark Brown
2018-02-14 16:04       ` Mark Brown
2018-02-14 16:28     ` Applied "spi: bcm2835aux: Avoid 64-bit arithmetic in xfer len calc" to the spi tree Mark Brown
2018-02-14 16:28       ` Mark Brown

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.