]> git.baikalelectronics.ru Git - kernel.git/commitdiff
spi: fix SPI_BIT_MASK so it always fits into 32-bits
authorStephen Warren <swarren@nvidia.com>
Thu, 1 Aug 2013 22:08:57 +0000 (16:08 -0600)
committerMark Brown <broonie@linaro.org>
Fri, 2 Aug 2013 10:31:22 +0000 (11:31 +0100)
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>
Signed-off-by: Mark Brown <broonie@linaro.org>
include/linux/spi/spi.h

index 28e440be1c07aafaa4ac62470344b052f9107d8f..c920c2f4dad592a3cd17934334c36d3eb93d32f7 100644 (file)
@@ -309,7 +309,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))
 
        /* other constraints relevant to this driver */