Skip to content

Commit d3fbd45

Browse files
committed
spi: Use bitfields for multiple data lines
Trent Piepho observed that since the current realistic maximum number of data lines is four we can pack the spi_transfer struct more efficiently if we use a bitfield for the number of bits, allowing the fields to fit in a single byte along with cs_change. If space becomes an issue further optimiation is possible by only using the constants and packing the values chosen for them. Reported-by: Trent Piepho <tpiepho@gmail.com> Signed-off-by: Mark Brown <broonie@linaro.org>
1 parent a89e2d2 commit d3fbd45

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎include/linux/spi/spi.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,8 @@ struct spi_transfer {
576576
dma_addr_t rx_dma;
577577

578578
unsigned cs_change:1;
579-
u8 tx_nbits;
580-
u8 rx_nbits;
579+
unsigned tx_nbits:3;
580+
unsigned rx_nbits:3;
581581
#define SPI_NBITS_SINGLE 0x01 /* 1bit transfer */
582582
#define SPI_NBITS_DUAL 0x02 /* 2bits transfer */
583583
#define SPI_NBITS_QUAD 0x04 /* 4bits transfer */

0 commit comments

Comments
 (0)