This is a copy of Linux commit: 8<------------------------------------------------------------------------- commit 5d7e2b5ed5858fe739d4cb8ad22dcce7bd9dbe7b Author: Martin Sperl <kernel@xxxxxxxxxxxxxxxx> Date: Sat Feb 23 08:49:49 2019 +0000 spi: core: allow reporting the effectivly used speed_hz for a transfer Provide a means for the spi bus driver to report the effectively used spi clock frequency used for each spi_transfer. Signed-off-by: Martin Sperl <kernel@xxxxxxxxxxxxxxxx> Signed-off-by: Mark Brown <broonie@xxxxxxxxxx> 8<------------------------------------------------------------------------- to sync the spi core more with Linux which is required for the later core common message handling. Signed-off-by: Marco Felsch <m.felsch@xxxxxxxxxxxxxx> --- Changelog: v2: - no changes drivers/spi/spi.c | 1 + include/spi/spi.h | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index e8a0b1b84be5..78569301776f 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -415,6 +415,7 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message) message->spi = spi; list_for_each_entry(xfer, &message->transfers, transfer_list) { + xfer->effective_speed_hz = 0; if (!xfer->bits_per_word) xfer->bits_per_word = spi->bits_per_word; diff --git a/include/spi/spi.h b/include/spi/spi.h index 2061a44134d0..8458d890f4e6 100644 --- a/include/spi/spi.h +++ b/include/spi/spi.h @@ -333,6 +333,9 @@ static inline size_t spi_max_transfer_size(struct spi_device *spi) * @len: size of rx and tx buffers (in bytes) * @speed_hz: Select a speed other then the device default for this * transfer. If 0 the default (from @spi_device) is used. + * @effective_speed_hz: the effective SCK-speed that was used to + * transfer this transfer. Set to 0 if the SPI bus driver does + * not support it. * @bits_per_word: select a bits_per_word other then the device default * for this transfer. If 0 the default (from @spi_device) is used. * @cs_change: affects chipselect after this transfer completes @@ -402,6 +405,8 @@ struct spi_transfer { u16 delay_usecs; u32 speed_hz; + u32 effective_speed_hz; + struct list_head transfer_list; }; -- 2.39.5