Skip to content

Commit b6aa23c

Browse files
Stephen Warrenbroonie
authored andcommitted
spi: fix SPI_BIT_MASK so it always fits into 32-bits
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>
1 parent 5ae90d8 commit b6aa23c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎include/linux/spi/spi.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ struct spi_master {
309309
/* bitmask of supported bits_per_word for transfers */
310310
u32 bits_per_word_mask;
311311
#define SPI_BPW_MASK(bits) BIT((bits) - 1)
312-
#define SPI_BIT_MASK(bits) (((bits) == 32) ? ~0UL : (BIT(bits) - 1))
312+
#define SPI_BIT_MASK(bits) (((bits) == 32) ? ~0U : (BIT(bits) - 1))
313313
#define SPI_BPW_RANGE_MASK(min, max) (SPI_BIT_MASK(max) - SPI_BIT_MASK(min - 1))
314314

315315
/* other constraints relevant to this driver */

0 commit comments

Comments
 (0)