This is a note to let you know that I've just added the patch titled spi: consolidate setting message->spi to the 6.8-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: spi-consolidate-setting-message-spi.patch and it can be found in the queue-6.8 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 856ce6c20bb73b31ce8d77392e462b6aeae56ffa Author: David Lechner <dlechner@xxxxxxxxxxxx> Date: Tue Jan 23 15:49:46 2024 -0600 spi: consolidate setting message->spi [ Upstream commit b204aa0f99cfe3c9d796ecfc0bc6f3f89585789e ] Previously, __spi_sync() and __spi_async() set message->spi to the spi device independently after calling __spi_validate(). __spi_validate() also would conditionally set this if it needed to split the message since it wasn't set yet. Since both __spi_sync() and __spi_async() call __spi_validate(), we can consolidate this into only setting message->spi once (unconditionally) in __spi_validate(). This will also save any future callers of __spi_validate() from also needing to set message->spi. Signed-off-by: David Lechner <dlechner@xxxxxxxxxxxx> Link: https://msgid.link/r/20240123214946.2616786-1-dlechner@xxxxxxxxxxxx Signed-off-by: Mark Brown <broonie@xxxxxxxxxx> Stable-dep-of: c8bec3355f08 ("spi: move split xfers for CS_WORD emulation") Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index f2170f4b50775..8dfe635fffd63 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -4063,6 +4063,8 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message) if (list_empty(&message->transfers)) return -EINVAL; + message->spi = spi; + /* * If an SPI controller does not support toggling the CS line on each * transfer (indicated by the SPI_CS_WORD flag) or we are using a GPIO @@ -4075,9 +4077,6 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message) size_t maxsize = BITS_TO_BYTES(spi->bits_per_word); int ret; - /* spi_split_transfers_maxsize() requires message->spi */ - message->spi = spi; - ret = spi_split_transfers_maxsize(ctlr, message, maxsize, GFP_KERNEL); if (ret) @@ -4214,8 +4213,6 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message) if (!ctlr->transfer) return -ENOTSUPP; - message->spi = spi; - SPI_STATISTICS_INCREMENT_FIELD(ctlr->pcpu_statistics, spi_async); SPI_STATISTICS_INCREMENT_FIELD(spi->pcpu_statistics, spi_async); @@ -4395,8 +4392,6 @@ static int __spi_sync(struct spi_device *spi, struct spi_message *message) if (status != 0) return status; - message->spi = spi; - SPI_STATISTICS_INCREMENT_FIELD(ctlr->pcpu_statistics, spi_sync); SPI_STATISTICS_INCREMENT_FIELD(spi->pcpu_statistics, spi_sync);