linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: fix SPI_BIT_MASK so it always fits into 32-bits
@ 2013-08-01 22:08 Stephen Warren
  2013-08-02 10:31 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Warren @ 2013-08-01 22:08 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi, linux-kernel, Stephen Warren

From: Stephen Warren <swarren@nvidia.com>

On a 64-bit platform, ~0UL fills 64-bits, which causes SPI_BIT_MASK(32)
not to fit into 32 bits. This causes a warning when the result is assigned
to a 32-bit variable. Use ~0U instead to prevent this. This fixes:

drivers/spi/spi-gpio.c: In function 'spi_gpio_probe':
drivers/spi/spi-gpio.c:446:2: warning: large integer implicitly truncated to unsigned type [-Woverflow]

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 include/linux/spi/spi.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index c28ac12..8515190 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -314,7 +314,7 @@ struct spi_master {
 	/* bitmask of supported bits_per_word for transfers */
 	u32			bits_per_word_mask;
 #define SPI_BPW_MASK(bits) BIT((bits) - 1)
-#define SPI_BIT_MASK(bits) (((bits) == 32) ? ~0UL : (BIT(bits) - 1))
+#define SPI_BIT_MASK(bits) (((bits) == 32) ? ~0U : (BIT(bits) - 1))
 #define SPI_BPW_RANGE_MASK(min, max) (SPI_BIT_MASK(max) - SPI_BIT_MASK(min - 1))
 
 	/* limits on transfer speed */
-- 
1.8.1.5


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

* Re: [PATCH] spi: fix SPI_BIT_MASK so it always fits into 32-bits
  2013-08-01 22:08 [PATCH] spi: fix SPI_BIT_MASK so it always fits into 32-bits Stephen Warren
@ 2013-08-02 10:31 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2013-08-02 10:31 UTC (permalink / raw)
  To: Stephen Warren; +Cc: linux-spi, linux-kernel, Stephen Warren

[-- Attachment #1: Type: text/plain, Size: 357 bytes --]

On Thu, Aug 01, 2013 at 04:08:57PM -0600, Stephen Warren wrote:
> From: Stephen Warren <swarren@nvidia.com>
> 
> On a 64-bit platform, ~0UL fills 64-bits, which causes SPI_BIT_MASK(32)
> not to fit into 32 bits. This causes a warning when the result is assigned
> to a 32-bit variable. Use ~0U instead to prevent this. This fixes:

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2013-08-02 10:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-01 22:08 [PATCH] spi: fix SPI_BIT_MASK so it always fits into 32-bits Stephen Warren
2013-08-02 10:31 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).