Skip to contentSkip to conversation

spi: Use bitfields for multiple data lines

PATCH New Mark Brown 1 participant 1 message Jan 10, 2014 SPI

lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/1 spi: Use bitfields for multiple data lines

From: Mark Brown <[email protected]>

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.

---
 include/linux/spi/spi.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/spi/spi.h +2 -2
index 27a882978c15..77b529e418d5 100644
@@ -576,8 +576,8 @@ struct spi_transfer {
 	dma_addr_t	rx_dma;
 
 	unsigned	cs_change:1;
-	u8		tx_nbits;
-	u8		rx_nbits;
+	unsigned	tx_nbits:3;
+	unsigned	rx_nbits:3;
 #define	SPI_NBITS_SINGLE	0x01 /* 1bit transfer */
 #define	SPI_NBITS_DUAL		0x02 /* 2bits transfer */
 #define	SPI_NBITS_QUAD		0x04 /* 4bits transfer */
Signature · 6 lines
1.8.5.2

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html