spi: fix incorrect handling of min param in SPI_BPW_RANGE_MASK
authorStephen Warren <swarren@nvidia.com>
Thu, 30 May 2013 15:59:40 +0000 (09:59 -0600)
committerMark Brown <broonie@linaro.org>
Sat, 1 Jun 2013 18:46:16 +0000 (19:46 +0100)
SPI_BPW_RANGE_MASK is intended to work by calculating two masks; one
representing support for all bits up-to-and-including the "max" supported
value, and one representing support for all bits up-to-but-not-including
the "min" supported value, and then taking the difference between the
two, resulting in a mask representing support for all bits between
(inclusive) the min and max values.

However, the second mask ended up representing all bits up-to-and-
including rather up-to-but-not-including. Fix this bug.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
include/linux/spi/spi.h

index 3e9479134d9d5bf7ce9b0649ec0e46474ce065ba..28e440be1c07aafaa4ac62470344b052f9107d8f 100644 (file)
@@ -310,7 +310,7 @@ struct spi_master {
        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_BPW_RANGE_MASK(min, max) (SPI_BIT_MASK(max) - SPI_BIT_MASK(min))
+#define SPI_BPW_RANGE_MASK(min, max) (SPI_BIT_MASK(max) - SPI_BIT_MASK(min - 1))
 
        /* other constraints relevant to this driver */
        u16                     flags;
This page took 0.045215 seconds and 5 git commands to generate.