diff options
author | Mark Brown <broonie@kernel.org> | 2020-03-03 15:47:19 +0100 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2020-03-03 15:47:19 +0100 |
commit | 4709d86ca3c8f845ff653690b0a97ad19dc5ba18 (patch) | |
tree | 8d38b63919ee43334d9571b13123db080c91dd01 /drivers/spi | |
parent | Merge series "spi: spidev: Fix messages in spidev" from Oleksandr Suvorov <ol... (diff) | |
parent | spi: fsl-lpspi: remove unneeded array (diff) | |
download | linux-4709d86ca3c8f845ff653690b0a97ad19dc5ba18.tar.xz linux-4709d86ca3c8f845ff653690b0a97ad19dc5ba18.zip |
Merge series "trivial fixes for fsl-spi and spidev" from Oleksandr Suvorov <oleksandr.suvorov@toradex.com>:
- the memory optimization in fsl-spi
- the fix of the max speed setting bug in spidev
Oleksandr Suvorov (2):
spi: fsl-lpspi: remove unneeded array
spi: spidev: fix a max speed setting
drivers/spi/spi-fsl-lpspi.c | 7 ++-----
drivers/spi/spidev.c | 10 ++++++----
2 files changed, 8 insertions(+), 9 deletions(-)
--
2.24.1
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi-fsl-lpspi.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c index d0b8cc741a24..298329b781d2 100644 --- a/drivers/spi/spi-fsl-lpspi.c +++ b/drivers/spi/spi-fsl-lpspi.c @@ -86,8 +86,6 @@ #define TCR_RXMSK BIT(19) #define TCR_TXMSK BIT(18) -static int clkdivs[] = {1, 2, 4, 8, 16, 32, 64, 128}; - struct lpspi_config { u8 bpw; u8 chip_select; @@ -331,15 +329,14 @@ static int fsl_lpspi_set_bitrate(struct fsl_lpspi_data *fsl_lpspi) } for (prescale = 0; prescale < 8; prescale++) { - scldiv = perclk_rate / - (clkdivs[prescale] * config.speed_hz) - 2; + scldiv = perclk_rate / config.speed_hz / (1 << prescale) - 2; if (scldiv < 256) { fsl_lpspi->config.prescale = prescale; break; } } - if (prescale == 8 && scldiv >= 256) + if (scldiv >= 256) return -EINVAL; writel(scldiv | (scldiv << 8) | ((scldiv >> 1) << 16), |