]> git.baikalelectronics.ru Git - kernel.git/commit
spi: dw: Simplify the SPI bus speed config procedure
authorSerge Semin <Sergey.Semin@baikalelectronics.ru>
Wed, 7 Oct 2020 23:54:54 +0000 (02:54 +0300)
committerMark Brown <broonie@kernel.org>
Thu, 8 Oct 2020 22:00:08 +0000 (23:00 +0100)
commitc449ad7425aa2eb58f275ce977130918827b0d20
treec7c0e34925e50284751ee326de2f58ed603971a7
parentf76f3142c5fc90f67794f6649cecec86a6eb87b0
spi: dw: Simplify the SPI bus speed config procedure

The code currently responsible for the SPI communication speed setting up
is a bit messy. Most likely for some historical reason the bus frequency
is saved in the peripheral chip private data. It's pointless now since the
custom communication speed is a SPI-transfer-specific thing and only if
there is no SPI transfer data specified (like during the SPI memory
operations) it can be taken from the SPI device structure. But even in the
later case there is no point in having the clock divider and the SPI bus
frequency saved in the chip data, because the controller can be used for
both SPI-transfer-based and SPI-transfer-less communications. From
software point of view keeping the current clock divider in an SPI-device
specific storage may give a small performance gain (to avoid sometimes a
round-up division), but in comparison to the total SPI transfer time it
just doesn't worth saving a few CPU cycles in comparison to the total SPI
transfer time while having the harder to read code. The only optimization,
which could worth preserving in the code is to avoid unnecessary DW SPI
controller registers update if it's possible. So to speak let's simplify
the SPI communication speed update procedure by removing the clock-related
fields from the peripheral chip data and update the DW SPI clock divider
only if it's really changed. The later change is reached by keeping the
effective SPI bus speed in the internal DW SPI private data.

Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Link: https://lore.kernel.org/r/20201007235511.4935-6-Sergey.Semin@baikalelectronics.ru
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-dw-core.c