* [PATCH] spi: fix SPI_BIT_MASK() to use correct size for 32-bit transfer mask
@ 2013-08-20 12:15 Mika Westerberg
2013-08-20 16:37 ` Stephen Warren
0 siblings, 1 reply; 3+ messages in thread
From: Mika Westerberg @ 2013-08-20 12:15 UTC (permalink / raw)
To: linux-spi; +Cc: Mark Brown, Stephen Warren, Mika Westerberg, linux-kernel
When building a 64-bit kernel we get the following warning from the
compiler:
drivers/spi/spi-pxa2xx.c: In function ‘pxa2xx_spi_probe’:
drivers/spi/spi-pxa2xx.c:1152:3: warning: large integer implicitly truncated to unsigned type [-Woverflow]
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32);
^
This is due the fact that when the max range is specified as 32
SPI_BIT_MASK() expands to ~0UL which doesn't fit to the u32 type that the
master->bits_per_word_mask is.
Fix this by using ~0U instead.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.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 28e440b..c920c2f 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -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 */
--
1.8.4.rc2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] spi: fix SPI_BIT_MASK() to use correct size for 32-bit transfer mask
2013-08-20 12:15 [PATCH] spi: fix SPI_BIT_MASK() to use correct size for 32-bit transfer mask Mika Westerberg
@ 2013-08-20 16:37 ` Stephen Warren
2013-08-21 7:44 ` Mika Westerberg
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Warren @ 2013-08-20 16:37 UTC (permalink / raw)
To: Mika Westerberg; +Cc: linux-spi, Mark Brown, Stephen Warren, linux-kernel
On 08/20/2013 06:15 AM, Mika Westerberg wrote:
> When building a 64-bit kernel we get the following warning from the
> compiler:
>
> drivers/spi/spi-pxa2xx.c: In function ‘pxa2xx_spi_probe’:
> drivers/spi/spi-pxa2xx.c:1152:3: warning: large integer implicitly truncated to unsigned type [-Woverflow]
> master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32);
> ^
> This is due the fact that when the max range is specified as 32
> SPI_BIT_MASK() expands to ~0UL which doesn't fit to the u32 type that the
> master->bits_per_word_mask is.
>
> Fix this by using ~0U instead.
The same patch is already in next-20130819 at least, as:
b6aa23c spi: fix SPI_BIT_MASK so it always fits into 32-bits
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] spi: fix SPI_BIT_MASK() to use correct size for 32-bit transfer mask
2013-08-20 16:37 ` Stephen Warren
@ 2013-08-21 7:44 ` Mika Westerberg
0 siblings, 0 replies; 3+ messages in thread
From: Mika Westerberg @ 2013-08-21 7:44 UTC (permalink / raw)
To: Stephen Warren; +Cc: linux-spi, Mark Brown, Stephen Warren, linux-kernel
On Tue, Aug 20, 2013 at 10:37:34AM -0600, Stephen Warren wrote:
> On 08/20/2013 06:15 AM, Mika Westerberg wrote:
> > When building a 64-bit kernel we get the following warning from the
> > compiler:
> >
> > drivers/spi/spi-pxa2xx.c: In function ‘pxa2xx_spi_probe’:
> > drivers/spi/spi-pxa2xx.c:1152:3: warning: large integer implicitly truncated to unsigned type [-Woverflow]
> > master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32);
> > ^
> > This is due the fact that when the max range is specified as 32
> > SPI_BIT_MASK() expands to ~0UL which doesn't fit to the u32 type that the
> > master->bits_per_word_mask is.
> >
> > Fix this by using ~0U instead.
>
> The same patch is already in next-20130819 at least, as:
> b6aa23c spi: fix SPI_BIT_MASK so it always fits into 32-bits
Cool :) Thanks for letting me know.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-08-21 7:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-20 12:15 [PATCH] spi: fix SPI_BIT_MASK() to use correct size for 32-bit transfer mask Mika Westerberg
2013-08-20 16:37 ` Stephen Warren
2013-08-21 7:44 ` Mika Westerberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox