Skip to content

Commit 2922a8d

Browse files
swarrenbroonie
authored andcommitted
spi: introduce macros to set bits_per_word_mask
Introduce two macros to make setting up spi_master.bits_per_word_mask easier, and avoid mistakes like writing BIT(n) instead of BIT(n - 1). SPI_BPW_MASK is for a single supported value of bits_per_word_mask. SPI_BPW_RANGE_MASK represents a contiguous set of bit lengths. Signed-off-by: Stephen Warren <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent c778879 commit 2922a8d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

include/linux/spi/spi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,8 @@ struct spi_master {
308308

309309
/* bitmask of supported bits_per_word for transfers */
310310
u32 bits_per_word_mask;
311+
#define SPI_BPW_MASK(bits) BIT((bits) - 1)
312+
#define SPI_BPW_RANGE_MASK(min, max) ((BIT(max) - 1) - (BIT(min) - 1))
311313

312314
/* other constraints relevant to this driver */
313315
u16 flags;

0 commit comments

Comments
 (0)