All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] spi: consolidate setting message->spi
@ 2024-01-23 21:49 David Lechner
  2024-01-24 18:40 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: David Lechner @ 2024-01-23 21:49 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi, linux-kernel, David Lechner

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@baylibre.com>
---
 drivers/spi/spi.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index bc3d7c0ce6b4..7a70ef47cdf6 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -4059,6 +4059,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
@@ -4071,9 +4073,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)
@@ -4210,8 +4209,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);
 
@@ -4391,8 +4388,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);
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] spi: consolidate setting message->spi
  2024-01-23 21:49 [PATCH] spi: consolidate setting message->spi David Lechner
@ 2024-01-24 18:40 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2024-01-24 18:40 UTC (permalink / raw)
  To: David Lechner; +Cc: linux-spi, linux-kernel

On Tue, 23 Jan 2024 15:49:46 -0600, David Lechner wrote:
> 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.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: consolidate setting message->spi
      commit: b204aa0f99cfe3c9d796ecfc0bc6f3f89585789e

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-24 18:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-23 21:49 [PATCH] spi: consolidate setting message->spi David Lechner
2024-01-24 18:40 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.