Skip to content

Commit 9d77522

Browse files
tititiou36broonie
authored andcommitted
spi: Reorder fields in 'struct spi_transfer'
Group some variables based on their sizes to reduce hole and avoid padding. On x86_64, this shrinks the size from 144 to 128 bytes. Turn 'timestamped' into a bitfield so that it can be easily merged with some other bifields and move 'error'. This should have no real impact on memory allocation because 'struct spi_transfer' is mostly used on stack, but it can save a few cycles when the structure is initialized or copied. Signed-off-by: Christophe JAILLET <[email protected]> Link: https://lore.kernel.org/r/93a051da85a895bc6003aedfb00a13e1c2fc6338.1676370870.git.christophe.jaillet@wanadoo.fr Signed-off-by: Mark Brown <[email protected]>
1 parent 937ca91 commit 9d77522

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

drivers/spi/spi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1927,7 +1927,7 @@ void spi_take_timestamp_post(struct spi_controller *ctlr,
19271927
/* Capture the resolution of the timestamp */
19281928
xfer->ptp_sts_word_post = progress;
19291929

1930-
xfer->timestamped = true;
1930+
xfer->timestamped = 1;
19311931
}
19321932
EXPORT_SYMBOL_GPL(spi_take_timestamp_post);
19331933

include/linux/spi/spi.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,9 @@ struct spi_transfer {
10221022
void *rx_buf;
10231023
unsigned len;
10241024

1025+
#define SPI_TRANS_FAIL_NO_START BIT(0)
1026+
u16 error;
1027+
10251028
dma_addr_t tx_dma;
10261029
dma_addr_t rx_dma;
10271030
struct sg_table tx_sg;
@@ -1032,6 +1035,7 @@ struct spi_transfer {
10321035
unsigned cs_change:1;
10331036
unsigned tx_nbits:3;
10341037
unsigned rx_nbits:3;
1038+
unsigned timestamped:1;
10351039
#define SPI_NBITS_SINGLE 0x01 /* 1bit transfer */
10361040
#define SPI_NBITS_DUAL 0x02 /* 2bits transfer */
10371041
#define SPI_NBITS_QUAD 0x04 /* 4bits transfer */
@@ -1048,12 +1052,7 @@ struct spi_transfer {
10481052

10491053
struct ptp_system_timestamp *ptp_sts;
10501054

1051-
bool timestamped;
1052-
10531055
struct list_head transfer_list;
1054-
1055-
#define SPI_TRANS_FAIL_NO_START BIT(0)
1056-
u16 error;
10571056
};
10581057

10591058
/**

0 commit comments

Comments
 (0)